#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 19;
const int p = 1e5 + 19;
const int mod = 1e9 + 7;
int mul(int a, int b) { return (long long)a * b % mod; }
int sum(int a, int b) { return (a + b) % mod; }
int sub(int a, int b) { return (a + mod - b) % mod; }
int pwp[2 * maxn];
void make() {
  pwp[0] = 1;
  for (int i = 1; i < 2 * maxn; i++) {
    pwp[i] = mul(pwp[i - 1], p);
  }
}
struct hash_ {
  vector<int> h;
  vector<int> re;
  int n;
  hash_() {}
  hash_(int n_) {
    n = n_;
    h.assign(1, 0);
    re.assign(1, 0);
  }
  void add(int c) {
    h.push_back(sum(h[n], mul(c, pwp[maxn - n])));
    re.push_back(sum(re[n], mul(c, pwp[n])));
    n++;
  }
  void add(vector<int> s) {
    for (int i = 0; i < s.size(); i++) {
      add(s[i]);
    }
  }
  void del(int l) {
    h.resize(l + 1);
    re.resize(l + 1);
    n = l;
  }
  int get_h(int l, int r) { return mul(sub(h[r], h[l]), pwp[r - 1]); }
  int get_r(int l, int r) { return mul(sub(re[r], re[l]), pwp[maxn - l]); }
};
int ansver = 0;
hash_ h;
int move_ = 1;
vector<int> bord;
int pos = 1;
int len = 1;
vector<int> new_s;
void show() {
  return;
  cout << "len = " << len << '\n';
  cout << "pos = " << pos << '\n';
  cout << "new_s :  ";
  for (auto i : new_s) {
    cout << i << ' ';
  }
  cout << '\n';
  cout << "move = " << move_ << '\n';
  cout << "bord : ";
  for (auto i : bord) {
    cout << i << ' ';
  }
  cout << '\n';
  cout << "ans = " << ansver << "\n\n";
}
void add(int c) {
  h.add(c);
  new_s.push_back(c);
  pos += move_;
  len++;
  show();
}
void easy_reverse() {
  int l1 = (len + 1) / 2;
  vector<int> s1;
  for (int i = l1 - 1; i >= 0; i--) {
    s1.push_back(new_s[i]);
  }
  new_s = s1;
  h.del(0);
  h.add(new_s);
  len = l1;
  pos = l1;
  move_ = 1;
  bord.pop_back();
  show();
}
void add_up(int c) {
  int p = bord[bord.size() - 2];
  if (p == pos + move_) {
    int l = 2 * abs(pos - bord.back()) + 1;
    len -= l;
    h.del(len);
    new_s.resize(len);
    pos += move_;
    bord.pop_back();
    bord.pop_back();
  } else {
    h.add(c);
    new_s.push_back(c);
    pos += move_;
    len++;
  }
  show();
}
void rev(int c) {
  ansver++;
  if (bord.back() == pos - move_) {
    if (len == 1) {
      return;
    } else {
      len--;
      pos -= move_;
      new_s.pop_back();
      h.del(len);
      bord.pop_back();
      move_ = -move_;
    }
    return;
  }
  h.add(c);
  new_s.push_back(c);
  len++;
  bord.push_back(pos);
  pos -= move_;
  move_ = -move_;
  show();
}
void unequal(int c) {
  new_s.push_back(c);
  h.add(c);
  len++;
  if (move_ == -1) {
    pos--;
  } else {
    pos++;
  }
  int l = 0;
  while (1) {
    ansver--;
    move_ = -move_;
    l += abs(pos - bord.back());
    pos = bord.back();
    bord.pop_back();
    if (move_ == -1) {
      int l1 = min(pos, l);
      int hh1 = h.get_h(pos - l, pos);
      int hh2 = h.get_r(len - l, len - l + l1);
      if (hh1 == hh2) {
        break;
      }
    } else {
      if (bord.size() == 1) {
        break;
      }
      int l1 = min(bord[1] - pos, l);
      int hh1 = h.get_h(pos, pos + l1);
      int hh2 = h.get_h(len - l, len - l + l1);
      if (hh1 == hh2) {
        break;
      }
    }
  }
  if (bord.size() == 1) {
    pos = len;
    show();
    return;
  }
  vector<int> s1;
  for (int i = len - l; i < len; i++) {
    s1.push_back(new_s[i]);
  }
  int l1 = 0;
  if (move_ == 1) {
    while (bord.size() > 1) {
      int p1 = bord[bord.size() - 2];
      if (p1 > pos + l) {
        break;
      }
      l1 += 2 * (pos - bord.back());
      l1 += 2 * (bord[bord.size() - 2] - pos);
      bord.pop_back(), bord.pop_back();
    }
    len -= l + l1;
    h.del(len);
    new_s.resize(len);
    for (int i = 0; i < l; i++) {
      add(s1[i]);
    }
  } else {
    while (bord.size() > 2) {
      int p1 = bord[bord.size() - 2];
      if (p1 < pos - l) {
        break;
      }
      l1 += 2 * (bord.back() - pos);
      l1 += 2 * (pos - bord[bord.size() - 2]);
      bord.pop_back(), bord.pop_back();
    }
    if (pos - l <= 0) {
      vector<int> s0;
      for (int i = bord[1] - 1; i >= pos; i--) {
        s0.push_back(new_s[i]);
      }
      len = 0;
      bord.pop_back();
      pos = 0;
      h.del(0);
      new_s.resize(0);
      move_ = 1;
      for (auto i : s0) {
        add(i);
      }
      for (auto i : s1) {
        add(i);
      }
    } else {
      len -= l + l1;
      h.del(len);
      new_s.resize(len);
      for (int i = 0; i < l; i++) {
        add(s1[i]);
      }
    }
  }
  show();
}
int n;
vector<int> s;
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  make();
  cin >> n;
  s.resize(n);
  cin >> s[0];
  h = hash_(0);
  h.add(s[0]);
  bord.push_back(0);
  new_s.push_back(s[0]);
  for (int i = 1; i < n; i++) {
    cout << ansver << ' ';
    cin >> s[i];
    int c = s[i];
    if (c == new_s[pos - (move_ == 1)]) {
      rev(c);
      continue;
    }
    if (move_ == 1 && pos == len) {
      add(c);
      continue;
    }
    if (move_ == -1 && pos == 1 && new_s[0] == c) {
      easy_reverse();
      continue;
    }
    if (c == new_s[pos - (move_ == -1)]) {
      add_up(c);
      continue;
    }
    unequal(c);
  }
  cout << ansver << ' ';
  return 0;
}
