#include <bits/stdc++.h>
using namespace std;
const int N = (int)2e6 + 100;
int n;
char s[N];
int z[N];
pair<int, int> st[N];
int m;
int ans[N];
int main() {
  scanf("%d", &n);
  scanf("%s", s);
  for (int i = n - 1; i > 0; i--) s[2 * i] = s[i];
  for (int i = 1; i < 2 * n; i += 2) s[i] = s[2 * n - 1 - i];
  int l = 0, r = 0;
  for (int i = 1; i < n; i++) {
    if (i <= r) z[i] = min(r - i + 1, z[l + r - i + 1]);
    while (i > z[i] && s[i - z[i] - 1] == s[i + z[i]]) z[i]++;
    if (i + z[i] - 1 > r) {
      l = i - z[i];
      r = i + z[i] - 1;
    }
  }
  for (int i = 1; i < n; i += 2) {
    l = i - z[i];
    while (m > 0 && st[m - 1].first >= l) m--;
    st[m++] = make_pair(l, i);
  }
  for (int i = 0; i <= n; i++) ans[i] = -1;
  for (int i = 0; i < m; i++) {
    r = st[i].second;
    if (i + 1 < m) r = min(r, st[i + 1].first);
    for (int j = st[i].first; j < r; j++) ans[j] = st[i].second - j;
  }
  for (int i = 0; i < n; i += 2) printf("%d ", ans[i]);
  printf("\n");
  return 0;
}
