#include <bits/stdc++.h>
using namespace std;
int n;
int a[100050], num[100050], oc[100050];
inline void read(int &x) {
  x = 0;
  register char ch = getchar();
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
}
int main() {
  read(n);
  for (register int i = 1; i <= n; i++) {
    read(a[i]);
    num[a[i]]++;
  }
  int tot = 0;
  for (register int i = 1; i <= n; i++) {
    if (num[i] & 1) tot++;
  }
  if ((n % 2 == 0 && tot) || (n % 2 && tot > 1)) {
    cout << 0 << endl;
    return 0;
  }
  int len = 0;
  for (register int i = 1; i <= (n >> 1); i++) {
    if (a[i] != a[n - i + 1]) {
      len = i;
      break;
    }
    num[a[i]] -= 2;
  }
  if (len == 0) {
    cout << (long long)n * (n + 1) / 2 << endl;
    return 0;
  }
  int le = 0, ri = 0;
  for (register int i = len; i <= n; i++) {
    oc[a[i]]++;
    if (oc[a[i]] * 2 > num[a[i]]) {
      if (a[i] != a[n - i + 1]) break;
      if (i < n - i + 1) break;
      if (num[a[i]] % 2 == 0 && i == n - i + 1) break;
    }
    le++;
  }
  memset(oc, 0, sizeof(oc));
  for (register int i = n - len + 1; i >= 1; i--) {
    oc[a[i]]++;
    if (oc[a[i]] * 2 > num[a[i]]) {
      if (a[i] != a[n - i + 1]) break;
      if (i > n - i + 1) break;
      if (num[a[i]] % 2 == 0 && i == n - i + 1) break;
    }
    ri++;
  }
  cout << (long long)len * (len + le + ri) << endl;
}
