{"raw_statement":[{"iden":"problem statement","content":"There is an empty sequence $X$ and an empty stack $S$. Also, you are given an integer sequence $A=(a_1,\\ldots,a_N)$ of length $N$.  \nFor each $i=1,\\ldots,N$ in this order, Takahashi will do one of the following operations:\n\n*   Move the integer $a_i$ onto the top of $S$.\n*   Discard the integer $a_i$ from $A$.\n\nAdditionally, Takahashi may do the following operation whenever $S$ is not empty:\n\n*   Move the integer at the top of $S$ to the tail of $X$.\n\nThe score of the final $X$ is defined as follows.\n\n*   If $X$ is non-decreasing, i.e. if $x_i \\leq x_{i+1}$ holds for all integer $i(1 \\leq i \\lt |X|)$, where $X=(x_1,\\ldots,x_{|X|})$, then the score is $|X|$ (where $|X|$ denotes the number of terms in $X$).\n*   If $X$ is not non-decreasing, then the score is $0$.\n\nFind the maximum possible score."},{"iden":"constraints","content":"*   $1 \\leq N \\leq 50$\n*   $1 \\leq a_i \\leq 50$\n*   All values in input are integers."},{"iden":"input","content":"Input is given from Standard Input in the following format:\n\n$N$\n$a_1$ $\\ldots$ $a_N$"},{"iden":"sample input 1","content":"7\n1 2 3 4 1 2 3"},{"iden":"sample output 1","content":"5\n\nThe following operations make the final $X$ equal $(1,1,2,3,4)$, for a score of $5$.\n\n*   Move $a_1=1$ onto the top of $S$.\n*   Move $1$ at the top of $S$ to the tail of $X$.\n*   Move $a_2=2$ onto the top of $S$.\n*   Discard $a_3=3$.\n*   Move $a_4=4$ onto the top of $S$.\n*   Move $a_5=1$ onto the top of $S$.\n*   Move $1$ at the top of $S$ to the tail of $X$.\n*   Move $a_6=2$ onto the top of $S$.\n*   Move $2$ at the top of $S$ to the tail of $X$.\n*   Move $a_7=3$ onto the top of $S$.\n*   Move $3$ at the top of $S$ to the tail of $X$.\n*   Move $4$ at the top of $S$ to the tail of $X$.\n\nWe cannot make the score $6$ or greater, so the maximum possible score is $5$."},{"iden":"sample input 2","content":"10\n1 1 1 1 1 1 1 1 1 1"},{"iden":"sample output 2","content":"10"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}