#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= mod;
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
const int N = 101000;
int n, a[N], cnt, ct[N], lim[N];
long long ans;
vector<int> pos[N];
set<pair<int, int> > hs;
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n + 1; i++) {
    scanf("%d", a + i);
    pos[a[i]].push_back(i);
  }
  for (int i = 1; i < n + 1; i++)
    if (((int)(pos[i]).size()) % 2 == 1) cnt++;
  if (cnt > 1) {
    puts("0");
    return 0;
  }
  cnt = 0;
  for (int i = 1; i < n + 1; i++) cnt += (a[i] == a[n + 1 - i]);
  if (cnt == n) {
    printf("%I64d\n", 1ll * n * (n + 1) / 2);
    return 0;
  }
  int md = n / 2;
  int l = 1;
  while (a[l] == a[n + 1 - l]) l++;
  --l;
  int r = 1;
  while (a[md + 1 - r] == a[n - md + r]) r++;
  --r;
  for (int i = l + 1; i < md + 1 - r; i++) ct[a[i]]++, ct[a[n + 1 - i]]--;
  cnt = 0;
  for (int i = 1; i < n + 1; i++) cnt += (ct[i] != 0);
  if (cnt == 0) ans += 2 * (l + 1ll) * (r + 1ll);
  md = (n + 1) / 2;
  for (int i = 1; i < n + 1; i++) {
    if (((int)(pos[i]).size()) == 0)
      lim[i] = md;
    else
      lim[i] = min(md, pos[i][((int)(pos[i]).size()) / 2]);
  }
  for (int i = 1; i < n + 1; i++) ct[i] = ((int)(pos[i]).size());
  for (int i = 1; i < n + 1; i++)
    if (ct[i]) {
      hs.insert(make_pair(lim[i], i));
    }
  for (int i = 1; i < md + 1; i++) {
    ans += hs.begin()->first - i + 1;
    if (a[i] != a[n + 1 - i]) break;
    ct[a[i]] -= 2;
    if (ct[a[i]] == 0) hs.erase(make_pair(lim[a[i]], a[i]));
  }
  for (int i = 1; i < n + 1; i++) pos[a[i]].clear();
  reverse(a + 1, a + n + 1);
  for (int i = 1; i < n + 1; i++) pos[a[i]].push_back(i);
  hs.clear();
  for (int i = 1; i < n + 1; i++) {
    if (((int)(pos[i]).size()) == 0)
      lim[i] = md;
    else
      lim[i] = min(md, pos[i][((int)(pos[i]).size()) / 2]);
  }
  for (int i = 1; i < n + 1; i++) ct[i] = ((int)(pos[i]).size());
  for (int i = 1; i < n + 1; i++)
    if (ct[i]) {
      hs.insert(make_pair(lim[i], i));
    }
  for (int i = 1; i < md + 1; i++) {
    ans += hs.begin()->first - i;
    if (a[i] != a[n + 1 - i]) break;
    ct[a[i]] -= 2;
    if (ct[a[i]] == 0) hs.erase(make_pair(lim[a[i]], a[i]));
  }
  printf("%I64d\n", ans);
}
