#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 5;
int a[MAX], f[MAX], n;
bool pal() {
  for (long long i = 0; i < (long long)(n); i++) {
    if (a[i] != a[n - i - 1]) return 0;
  }
  return 1;
}
bool pos(int l, int r) {
  memset(f, 0, sizeof(f));
  for (long long i = l; i < (long long)(r + 1); i++) f[a[i]]++;
  for (long long i = l; i < (long long)(r + 1); i++) {
    if (n - i - 1 < l or n - i - 1 > r) f[a[n - i - 1]]--;
  }
  int cnt = 0;
  for (long long i = 0; i < (long long)(n + 1); i++) {
    if (f[i] < 0) return 0;
    if (f[i] % 2) cnt++;
  }
  for (long long i = 0; i < (long long)(n); i++) {
    if ((i < l or i > r) and (n - i - 1 < l or n - i - 1 > r)) {
      if (a[i] != a[n - i - 1]) return 0;
    }
  }
  if (cnt > 1) return 0;
  return 1;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  memset(f, 0, sizeof(f));
  for (long long i = 0; i < (long long)(n); i++) {
    cin >> a[i];
    f[a[i]]++;
  }
  int cnt = 0;
  for (long long i = 0; i < (long long)(n + 1); i++) {
    if (f[i] % 2) cnt++;
  }
  if (cnt > 1) {
    cout << "0" << endl;
    return 0;
  }
  long long ans = 0;
  if (pal()) {
    ans = (long long)n * (n + 1) / 2;
    cout << ans << endl;
    return 0;
  }
  int l = 0, r = n - 1;
  while (true) {
    if (a[l] != a[r]) break;
    l++, r--;
  }
  int hi, lo, mid;
  hi = r, lo = l;
  while (hi - lo > 1) {
    mid = (hi + lo) / 2;
    if (pos(l, mid))
      hi = mid;
    else
      lo = mid + 1;
  }
  int x = pos(l, lo) ? lo : hi;
  x = (x - l + 1);
  hi = r, lo = l;
  while (hi - lo > 1) {
    mid = (hi + lo) / 2;
    if (pos(mid, r))
      lo = mid;
    else
      hi = mid - 1;
  }
  int y = pos(hi, r) ? hi : lo;
  y = (r - y + 1);
  int m = r - l + 1;
  ans = (long long)((n - m) / 2 + 1) * ((n - m) / 2 + 2 * m + 1 - x - y);
  cout << ans << endl;
  return 0;
}
