#P1394E. Boboniu and Banknote Collection
Boboniu and Banknote Collection
No submission language available for this problem.
Description
No matter what trouble you're in, don't be afraid, but face it with a smile.
I've made another billion dollars!
— Boboniu
Boboniu has issued his currencies, named Bobo Yuan. Bobo Yuan (BBY) is a series of currencies. Boboniu gives each of them a positive integer identifier, such as BBY-1, BBY-2, etc.
Boboniu has a BBY collection. His collection looks like a sequence. For example:

We can use sequence of length to denote it.
Now Boboniu wants to fold his collection. You can imagine that Boboniu stick his collection to a long piece of paper and fold it between currencies:

Boboniu will only fold the same identifier of currencies together. In other words, if is folded over (), then must hold. Boboniu doesn't care if you follow this rule in the process of folding. But once it is finished, the rule should be obeyed.
A formal definition of fold is described in notes.
According to the picture above, you can fold two times. In fact, you can fold at most two times. So the maximum number of folds of it is .
As an international fan of Boboniu, you're asked to calculate the maximum number of folds.
You're given a sequence of length , for each (), you need to calculate the maximum number of folds of .
The first line contains an integer ().
The second line contains integers ().
Print integers. The -th of them should be equal to the maximum number of folds of .
Input
The first line contains an integer ().
The second line contains integers ().
Output
Print integers. The -th of them should be equal to the maximum number of folds of .
Samples
Note
Formally, for a sequence of length , let's define the folding sequence as a sequence of length such that:
- () is either or .
- Let . For all , if , then should be equal to .
( is the value of boolean expression . i. e. if is true, else ).
Now we define the number of folds of as .
The maximum number of folds of is .