There are $2N$ cards bearing positive integers. They are arranged in a row from left to right.
Each card bears exactly one positive integer between $1$ and $N$, inclusive. Let $X_i$ be the number on the $i$-th card from the left ($1\le i\le2N$).
For each $k$ with $1\le k\le N$, exactly two cards bear $k$. In other words, each positive integer from $1$ to $N$ appears on exactly two cards.
정올이 calls the number of cards lying between the two cards bearing the positive integer $k$ the "number of cards between $k$".
For example, consider the arrangement in the figure below. Here $N=4$ and $X_1=1,X_2=2,X_3=2,X_4=4,X_5=3,X_6=1,X_7=3,X_8=4$.
- Between the two cards bearing $1$ are cards bearing $2,2,4,3$ in order, so the number of cards between $1$ is $4$.
- There are no cards between the two cards bearing $2$, so the number of cards between $2$ is $0$.
- Only the card bearing $1$ lies between the two cards bearing $3$, so the number of cards between $3$ is $1$.
- Between the two cards bearing $4$ are cards bearing $3,1,3$ in order, so the number of cards between $4$ is $3$.
In this example, the greatest number of cards between any $k$ is the number of cards between $1$, which is $4$.
정올이 wants to find the greatest number of cards between $k$ over all positive integers $k$ from $1$ to $N$.
Given the numbers on the cards in their arranged order, write a program that finds the greatest number of cards between any $k$.
Constraints
- All given numbers are integers.
- $1\le N\le2\,000$
- For each $i$ ($1\le i\le2N$): $1\le X_i\le N$
- For each $k$ ($1\le k\le N$), the number appears exactly twice among $X_1,X_2,\ldots,X_{2N}$.
Subtasks
- (10 points) $N\le2$
- (15 points) The answer is $0$ or $1$.
- (15 points) The answer is $2N-3$ or $2N-2$.
- (20 points) $N\le500$
- (40 points) No additional constraints.
Input
The first line contains the integer $N$.
The second line contains $2N$ integers $X_1,X_2,\ldots,X_{2N}$, separated by spaces.
Output
Print the answer on the first line.
Examples
Input 1
4 1 2 2 4 3 1 3 4
Output 1
4
Input 2
4 1 2 3 4 4 3 2 1
Output 2
6