#include <bits/stdc++.h>
struct MI {
 private:
  char bb[1 << 14];
  FILE *f;
  char *bs, *be;
  char e;
  bool o, l;

 public:
  MI() : f(stdin), bs(0), be(0) {}
  inline char get() {
    if (o) {
      o = 0;
      return e;
    }
    if (bs == be) be = (bs = bb) + fread(bb, 1, sizeof(bb), f);
    if (bs == be) {
      l = 1;
      return -1;
    };
    return *bs++;
  }
  inline void unget(char c) {
    o = 1;
    e = c;
  }
  template <class T>
  inline T read() {
    T r;
    *this > r;
    return r;
  }
  template <class T>
  inline MI &operator>(T &);
};
template <class T>
struct Q {
  const static bool U = T(-1) >= T(0);
  inline void operator()(MI &t, T &r) const {
    r = 0;
    char c;
    bool y = 0;
    if (U)
      for (;;) {
        c = t.get();
        if (c == -1) goto E;
        if (isdigit(c)) break;
      }
    else
      for (;;) {
        c = t.get();
        if (c == -1) goto E;
        if (c == '-') {
          c = t.get();
          if (isdigit(c)) {
            y = 1;
            break;
          };
        } else if (isdigit(c))
          break;
        ;
      };
    for (;;) {
      if (c == -1) goto E;
      if (isdigit(c))
        r = r * 10 + (c ^ 48);
      else
        break;
      c = t.get();
    }
    t.unget(c);
  E:;
    if (y) r = -r;
  }
};
template <>
struct Q<char> {};
template <class T>
inline MI &MI::operator>(T &t) {
  Q<T>()(*this, t);
  return *this;
}
template <class T>
std::ostream &operator<(std::ostream &out, const T &t) {
  return out << t;
}
using std::cout;
MI cin;
const int $n = 100005;
template <typename T>
inline bool gmax(T &a, const T &b) {
  return a < b && (a = b, true);
}
int n, v[$n];
std::basic_string<int> p[$n], rp[$n];
std::unordered_map<int, int> mem[$n];
int calc(int l, int r) {
  if (auto it = mem[r].find(l); it != mem[r].end()) return it->second;
  int &ans = mem[r][l];
  for (int d : p[r])
    if (r - d * 2 + 1 >= l) gmax(ans, calc(l, r - d) + 1);
  for (int d : rp[l])
    if (l + d * 2 - 1 <= r) gmax(ans, calc(l + d, r) + 1);
  return ans;
}
int main() {
  for (int T = (cin.read<int>()), b = 0; T;) {
    const int x = v[n + 1] = (cin.read<int>());
    if (v[n] == x) p[n + 1] += 1;
    for (int d : p[n])
      if (v[n - d * 2] == x) p[n + 1] += d + 1;
    ++n;
    for (int d : p[n]) rp[n - d * 2 + 1] += d;
    int s = 0;
    for (int d : p[n])
      if (std::binary_search(p[n - d].begin(), p[n - d].end(), d)) s = d;
    if (s) {
      b += 2;
      s <<= 1;
      while (s--) {
        assert(rp[n].empty());
        for (int d : p[n]) rp[n - d * 2 + 1].pop_back();
        p[n].clear();
        mem[n--].clear();
      }
    }
    cout < (b + calc(1, n)) < " \n"[!--T];
  }
}

### Prompt

Develop a solution in CPP to the problem described below:

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:

<image>

We can use sequence a=[1,2,3,3,2,1,4,4,1] of length n=9 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:

<image>

Boboniu will only fold the same identifier of currencies together. In other words, if a_i is folded over a_j (1≤ i,j≤ n), then a_i=a_j 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 a two times. In fact, you can fold a=[1,2,3,3,2,1,4,4,1] at most two times. So the maximum number of folds of it is 2.

As an international fan of Boboniu, you're asked to calculate the maximum number of folds. 

You're given a sequence a of length n, for each i (1≤ i≤ n), you need to calculate the maximum number of folds of [a_1,a_2,…,a_i].

Input

The first line contains an integer n (1≤ n≤ 10^5).

The second line contains n integers a_1,a_2,…,a_n (1≤ a_i≤ n).

Output

Print n integers. The i-th of them should be equal to the maximum number of folds of [a_1,a_2,…,a_i].

Examples

Input


9
1 2 3 3 2 1 4 4 1


Output


0 0 0 1 1 1 1 2 2


Input


9
1 2 2 2 2 1 1 2 2


Output


0 0 1 2 3 3 4 4 5


Input


15
1 2 3 4 5 5 4 3 2 2 3 4 4 3 6


Output


0 0 0 0 0 1 1 1 1 2 2 2 3 3 0


Input


50
1 2 4 6 6 4 2 1 3 5 5 3 1 2 4 4 2 1 3 3 1 2 2 1 1 1 2 4 6 6 4 2 1 3 5 5 3 1 2 4 4 2 1 3 3 1 2 2 1 1


Output


0 0 0 0 1 1 1 1 1 1 2 2 2 2 2 3 3 3 3 4 4 4 5 5 6 7 3 3 3 4 4 4 4 3 3 4 4 4 4 4 5 5 5 5 6 6 6 7 7 8

Note

Formally, for a sequence a of length n, let's define the folding sequence as a sequence b of length n such that:

  * b_i (1≤ i≤ n) is either 1 or -1. 
  * Let p(i)=[b_i=1]+∑_{j=1}^{i-1}b_j. For all 1≤ i<j≤ n, if p(i)=p(j), then a_i should be equal to a_j. 



([A] is the value of boolean expression A. i. e. [A]=1 if A is true, else [A]=0).

Now we define the number of folds of b as f(b)=∑_{i=1}^{n-1}[b_i≠ b_{i+1}].

The maximum number of folds of a is F(a)=max\{ f(b)∣ b  is a folding sequence of a \}.

### Response

```cpp
#include <bits/stdc++.h>
struct MI {
 private:
  char bb[1 << 14];
  FILE *f;
  char *bs, *be;
  char e;
  bool o, l;

 public:
  MI() : f(stdin), bs(0), be(0) {}
  inline char get() {
    if (o) {
      o = 0;
      return e;
    }
    if (bs == be) be = (bs = bb) + fread(bb, 1, sizeof(bb), f);
    if (bs == be) {
      l = 1;
      return -1;
    };
    return *bs++;
  }
  inline void unget(char c) {
    o = 1;
    e = c;
  }
  template <class T>
  inline T read() {
    T r;
    *this > r;
    return r;
  }
  template <class T>
  inline MI &operator>(T &);
};
template <class T>
struct Q {
  const static bool U = T(-1) >= T(0);
  inline void operator()(MI &t, T &r) const {
    r = 0;
    char c;
    bool y = 0;
    if (U)
      for (;;) {
        c = t.get();
        if (c == -1) goto E;
        if (isdigit(c)) break;
      }
    else
      for (;;) {
        c = t.get();
        if (c == -1) goto E;
        if (c == '-') {
          c = t.get();
          if (isdigit(c)) {
            y = 1;
            break;
          };
        } else if (isdigit(c))
          break;
        ;
      };
    for (;;) {
      if (c == -1) goto E;
      if (isdigit(c))
        r = r * 10 + (c ^ 48);
      else
        break;
      c = t.get();
    }
    t.unget(c);
  E:;
    if (y) r = -r;
  }
};
template <>
struct Q<char> {};
template <class T>
inline MI &MI::operator>(T &t) {
  Q<T>()(*this, t);
  return *this;
}
template <class T>
std::ostream &operator<(std::ostream &out, const T &t) {
  return out << t;
}
using std::cout;
MI cin;
const int $n = 100005;
template <typename T>
inline bool gmax(T &a, const T &b) {
  return a < b && (a = b, true);
}
int n, v[$n];
std::basic_string<int> p[$n], rp[$n];
std::unordered_map<int, int> mem[$n];
int calc(int l, int r) {
  if (auto it = mem[r].find(l); it != mem[r].end()) return it->second;
  int &ans = mem[r][l];
  for (int d : p[r])
    if (r - d * 2 + 1 >= l) gmax(ans, calc(l, r - d) + 1);
  for (int d : rp[l])
    if (l + d * 2 - 1 <= r) gmax(ans, calc(l + d, r) + 1);
  return ans;
}
int main() {
  for (int T = (cin.read<int>()), b = 0; T;) {
    const int x = v[n + 1] = (cin.read<int>());
    if (v[n] == x) p[n + 1] += 1;
    for (int d : p[n])
      if (v[n - d * 2] == x) p[n + 1] += d + 1;
    ++n;
    for (int d : p[n]) rp[n - d * 2 + 1] += d;
    int s = 0;
    for (int d : p[n])
      if (std::binary_search(p[n - d].begin(), p[n - d].end(), d)) s = d;
    if (s) {
      b += 2;
      s <<= 1;
      while (s--) {
        assert(rp[n].empty());
        for (int d : p[n]) rp[n - d * 2 + 1].pop_back();
        p[n].clear();
        mem[n--].clear();
      }
    }
    cout < (b + calc(1, n)) < " \n"[!--T];
  }
}

```