#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100010;
int a[MAXN], cnt[MAXN];
long long n;
int si, ej;
bool check(int l, int r) {
  if (r < n / 2) {
    for (int i = r + 1; i <= n / 2; i++) {
      if (a[i] != a[n - i + 1]) return false;
    }
  }
  int cnttmp[MAXN];
  memset(cnttmp, 0, sizeof(cnttmp));
  for (int i = l; i <= r; i++) cnttmp[a[i]]++;
  for (int i = ej; i > max((long long)r, n - r + 1); i--) cnttmp[a[i]]--;
  for (int i = 1; i <= n; i++) {
    if (cnttmp[a[i]] < 0) return false;
  }
  return true;
}
int compute(int lft) {
  int l = lft, r = ej;
  while (l < r) {
    int mid = (l + r) / 2;
    if (check(lft, mid)) {
      r = mid;
    } else
      l = mid + 1;
  }
  return r - lft + 1;
}
int main() {
  while (cin >> n) {
    memset(cnt, 0, sizeof(cnt));
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
      cnt[a[i]]++;
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
      if (cnt[i] % 2 == 1) ans++;
    }
    if (ans > 1) {
      cout << "0" << endl;
      continue;
    }
    si = 1, ej = n;
    while (si <= n && a[si] == a[ej]) {
      si++;
      ej--;
    }
    if (si >= ej) {
      cout << n * (n - 1) / 2 + n << endl;
      continue;
    }
    long long m = ej - si + 1;
    int pre = compute(si);
    reverse(a + 1, a + n + 1);
    int suf = compute(si);
    cout << ((n - m) / 2 + 1) * (2 * m + (n - m) / 2 - pre - suf + 1) << endl;
  }
  return 0;
}
