#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
int n;
int a[maxn], d[maxn];
int main(int argc, char* argv[]) {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]), d[a[i]] += 1;
  int cnt = 0;
  for (int i = 1; i <= n; i++) cnt += d[i] & 1;
  if (cnt > 1 || (cnt == 1 && (n & 1) == 0)) {
    cout << 0 << endl;
    return 0;
  }
  int m = 0, s = 1;
  for (int i = 1; i <= n / 2; i++) {
    if (a[i] != a[n - i + 1]) {
      s = i;
      m = n - (i - 1) * 2;
      break;
    }
  }
  if (m == 0) {
    cout << (long long)n * (n + 1) / 2 << endl;
    return 0;
  }
  for (int i = 1; i < s; i++) d[a[i]] -= 2;
  int prefix = 0;
  for (int i = s; i <= s + m / 2 - 1; i++) {
    if (d[a[i]] > 1) {
      prefix += 1;
      d[a[i]] -= 2;
    } else {
      break;
    }
  }
  if (prefix == m / 2) {
    if ((m % 2 != 0 && d[a[s + m / 2]] > 0) || m % 2 == 0) {
      for (int i = s + m / 2; i <= s + m - 1; i++) {
        if (a[i] == a[n - i + 1]) {
          prefix += 1;
        } else {
          break;
        }
      }
    }
  }
  for (int i = s; i <= s + prefix - 1; i++) d[a[i]] += 2;
  int suffix = 0;
  for (int i = s + m - 1; i >= s + (m - 1) / 2 + 1; i--) {
    if (d[a[i]] > 1) {
      suffix += 1;
      d[a[i]] -= 2;
    } else {
      break;
    }
  }
  if (suffix == m / 2) {
    if ((m % 2 != 0 && d[a[s + m / 2]] > 0) || m % 2 == 0) {
      for (int i = s + (m - 1) / 2; i >= s; i--) {
        if (a[i] == a[n - i + 1]) {
          suffix += 1;
        } else {
          break;
        }
      }
    }
  }
  long long res =
      (long long)((n - m) / 2 + 1) * ((n - m) / 2 + 1 + suffix + prefix);
  cout << res << endl;
  return 0;
}
