#P1236. A Difficult Exam For Ako Kagari

A Difficult Exam For Ako Kagari

题目描述

It is known that Ako,KagariAko\\,Kagari is not so good at using magic, that she even can't fly with broom. As the only witch without magic background in school, learning magic is a challenge to her and even the upcoming examinations have become her nightmare!

In a recent examination, she is given a sequence of balls Ball\\{Ball\\} with different numbers. Her teacher requires AkoAko to paint the balls with the following rule :"For each of these NN balls, She has to choose a color and paint the ball with that color by a specific magic . If some balls are painted with the same color, each two balls have to satisfy the condition : Balli<Ballj(i<j)Ball_i < Ball_j (i< j)".

Now, AkoAko wants your help to count what is the minimum number of magical skills she has to practice.

输入格式

In the first line, you are given the number NN(1leqNleq1051 \\leq N \\leq 10^5) .

In the second line, you are given the sequence of balls Ball1,Ball2,cdots,Balln\\{ Ball_1,Ball_2,\\cdots,Ball_n\\} (0leqBallileq1090 \\leq Ball_i \\leq 10^9) .

输出格式

Print the minimum number of magical skills AkoAko has to practice .

样例

5 
2 1 4 5 3
2
5 
5 5 5 5 5
5

提示

In Sample1:

AkoAko can pass the exam by, for example, painting 22 and 33 blue and painting 11, 44 and 55 green. So she has to practice 22 kinds of magical skills.

In Sample2:

All the balls have same number, so AkoAko has to paint the 55 balls with different color and practice 55 kinds of magical skills.