#include <bits/stdc++.h>
using namespace std;
int a[100001], n, cnt[100001], check[100001];
int main() {
  long long r = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    cnt[a[i]]++;
  }
  int odd = 0;
  for (int i = 0; i <= 100000; i++) {
    if (cnt[i] % 2) odd++;
  }
  if (odd > 1) {
    printf("0\n");
    return 0;
  }
  int start = -1;
  for (int i = 0; i < n; i++) {
    if (a[i] != a[n - i - 1]) {
      start = i;
      break;
    }
    cnt[a[i]] -= 2;
  }
  if (start == -1) {
    cout << (1LL * n * (n + 1) / 2LL) << endl;
    return 0;
  }
  for (int i = 0; i <= 100000; ++i) check[i] = 0;
  int ret = 0;
  for (int i = start; i <= n - start - 1; ++i) {
    check[a[i]]++;
    if (check[a[i]] * 2 > cnt[a[i]]) {
      if (i < n - i - 1) break;
      if (cnt[a[i]] % 2 == 0 and i == n - i - 1) break;
      if (a[i] != a[n - i - 1]) break;
    }
    ++ret;
  }
  for (int i = 0; i <= 100000; ++i) check[i] = 0;
  for (int i = n - start - 1; i >= 0; --i) {
    check[a[i]]++;
    if (check[a[i]] * 2 > cnt[a[i]]) {
      if (i > n - i - 1) break;
      if (cnt[a[i]] % 2 == 0 and i == n - i - 1) break;
      if (a[i] != a[n - i - 1]) break;
    }
    ++ret;
  }
  r += 1LL * ret * (start + 1);
  r += 1LL * (start + 1) * (start + 1);
  cout << r << endl;
  return 0;
}
