#include <bits/stdc++.h>
using namespace std;
int n;
int star[100005], num[100005];
int sum[100005];
long long C2(int x) {
  if (x < 2) return 0;
  return (long long)x * (long long)(x - 1) / 2LL;
}
bool inside(int id, int l, int r) {
  if (l <= id && id <= r)
    return true;
  else
    return false;
}
bool check(int l, int r) {
  memset(sum, 0, sizeof(sum));
  for (int i = 1; i <= n; i++) {
    if (!inside(i, l, r) && !inside(n - i + 1, l, r) &&
        star[i] != star[n - i + 1])
      return false;
  }
  for (int i = l; i <= r; i++) sum[star[i]]++;
  for (int i = 1; i <= n; i++) {
    if (!inside(i, l, r) && inside(n - i + 1, l, r)) {
      sum[star[i]]--;
      if (sum[star[i]] < 0) return false;
    }
  }
  return true;
}
long long solve() {
  int numOdd = 0;
  for (int i = 0; i <= n; i++) {
    if (num[i] % 2) numOdd++;
  }
  if (numOdd > 1 || (numOdd == 1 && n % 2 == 0)) return 0;
  int ll, lr, rl, rr;
  ll = -1;
  for (int i = 1; i <= n / 2; i++) {
    if (star[i] != star[n - i + 1]) {
      ll = i;
      rr = n - i + 1;
      break;
    }
  }
  if (ll == -1) return C2(n) + (long long)n;
  int l = ll - 1, r = n;
  while (r - l > 1) {
    int mid = (l + r) >> 1;
    if (check(ll, mid))
      r = mid;
    else
      l = mid;
  }
  lr = r;
  l = 1, r = rr + 1;
  while (r - l > 1) {
    int mid = (l + r) >> 1;
    if (check(mid, rr))
      l = mid;
    else
      r = mid;
  }
  rl = l;
  return ((long long)ll * (long long)(n - lr + 1) +
          (long long)rl * (long long)(n - rr + 1) -
          (long long)ll * (long long)(n - rr + 1));
}
int main() {
  while (scanf("%d", &n) != EOF) {
    memset(num, 0, sizeof(num));
    for (int i = 1; i <= n; i++) {
      scanf("%d", &star[i]);
      num[star[i]]++;
    }
    printf("%I64d\n", solve());
  }
  return 0;
}
