#include <bits/stdc++.h>
using namespace std;
int c[120000], d[120000], e[120000], g[120000];
int i, n, t, w, l, r;
long long s;
int main() {
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%d", &g[i]);
    d[g[i]]++;
  }
  t = 0;
  for (i = 0; i <= n; i++)
    if (d[i] & 1) t++;
  if (t > 1) {
    printf("%d", 0);
    return 0;
  }
  w = 0;
  for (r = n; r > 1; r--) {
    c[g[r]]++;
    if (c[g[r]] > d[g[r]] / 2)
      if (r > (n + 1) / 2)
        break;
      else
        w = 1;
    if ((w) && ((g[r] != g[n - r + 1]) ||
                ((r != n / 2 + 1) && (d[g[r]] & 1) && (g[r] != g[n / 2 + 1])) ||
                ((n & 1) && (r == n / 2 + 1) && (!(d[g[r]] & 1))))) {
      c[g[r]]--;
      break;
    }
  }
  s = n - r + 1;
  w = 0;
  for (l = 1; l < n; l++) {
    r = max(l + 1, r);
    if (g[l] != g[n - l + 1]) r = max(r, n - l + 1);
    e[g[l]]++;
    if (e[g[l]] > d[g[l]] / 2)
      if (l <= n / 2)
        break;
      else
        w = 1;
    if ((w) && ((g[l] != g[n - l + 1]) ||
                ((l != n / 2 + 1) && (d[g[l]] & 1) && (g[l] != g[n / 2 + 1])) ||
                ((n & 1) && (l == n / 2 + 1) && (!(d[g[l]] & 1)))))
      break;
    s = s + n - r + 1;
  }
  printf("%I64d", s);
  return 0;
}
