#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10, N = 1e5;
int cnt[maxn], a[maxn], cat[maxn];
int main() {
  int n, flag = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]), cnt[a[i]]++;
  for (int i = 1; i <= N; i++)
    if (cnt[i] & 1) flag++;
  if (flag > 1) return puts("0"), 0;
  int p = 0;
  for (int i = 1; i <= n && !p; i++)
    if (a[i] != a[n - i + 1])
      p = i;
    else
      cnt[a[i]] -= 2;
  if (!p) {
    cout << 1ll * n * (n + 1) / 2;
    return 0;
  }
  int res = 0;
  for (int i = p;; i++) {
    cat[a[i]]++;
    if (cat[a[i]] * 2 > cnt[a[i]]) {
      if (cnt[a[i]] % 2 && i != n - i + 1) break;
      if (cnt[a[i]] % 2 == 0 && i == n - i + 1) break;
      while (a[i] == a[n - i + 1] && i * 2 > n) res++, i++;
      break;
    }
    res++;
  }
  memset(cat, 0, sizeof(cat));
  for (int i = n - p + 1;; i--) {
    cat[a[i]]++;
    if (cat[a[i]] * 2 > cnt[a[i]]) {
      if (cnt[a[i]] % 2 && i != n - i + 1) break;
      if (cnt[a[i]] % 2 == 0 && i == n - i + 1) break;
      while (a[i] == a[n - i + 1] && i <= (n + 1) / 2) res++, i--;
      break;
    }
    res++;
  }
  cout << 1ll * p * (p + res);
}
