#include <bits/stdc++.h>
using namespace std;
int n, a[210000], sum[210000];
long long ans;
bool in(int k, int l, int r) { return l <= k && k <= r; }
bool can(int l, int r) {
  for (int i = 1; i <= n; i++) sum[i] = 0;
  for (int i = 1; i <= n; i++)
    if (!in(i, l, r) && !in(n - i + 1, l, r) && a[i] != a[n - i + 1])
      return false;
  for (int i = l; i <= r; i++) sum[a[i]]++;
  for (int i = 1; i <= n; i++)
    if (!in(i, l, r) && in(n - i + 1, l, r)) {
      sum[a[i]]--;
    }
  for (int i = 1; i <= n; i++)
    if (sum[a[i]] < 0) return false;
  return true;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]), sum[a[i]]++;
  int s = 0;
  for (int i = 1; i <= n; i++) s += sum[i] % 2;
  if (s > 1) {
    printf("0\n");
    return 0;
  }
  bool ok = true;
  for (int i = 1; i <= n; i++)
    if (a[i] != a[n - i + 1]) ok = false;
  if (ok) {
    printf("%I64d\n", 1LL * n * (n + 1) / 2);
    return 0;
  }
  int l = 1;
  while (a[l] == a[n - l + 1]) l++;
  int q = l - 1, h = n, mid;
  while (q < h - 1) {
    mid = (q + h) / 2;
    if (can(l, mid))
      h = mid;
    else
      q = mid;
  }
  ans += 1LL * l * (n - h + 1);
  for (int i = 1; i <= n - i + 1; i++) swap(a[i], a[n - i + 1]);
  q = l - 1;
  h = n;
  while (q < h - 1) {
    mid = (q + h) / 2;
    if (can(l, mid))
      h = mid;
    else
      q = mid;
  }
  ans += 1LL * l * (n - l + 1 - h);
  printf("%I64d\n", ans);
}
