#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 1e5 + 10;
long long a[MAXN], cnt[MAXN];
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n, id1 = -1;
  cin >> n;
  for (long long i = 0; i < n; i++) cin >> a[i];
  for (long long i = 0; i < n / 2; i++)
    if (a[i] != a[n - i - 1]) {
      id1 = i;
      break;
    }
  if (id1 == -1) {
    cout << 1ll * n * (n + 1) / 2 << endl;
    return 0;
  }
  long long id2 = n - 1 - id1, rem = (id2 - id1 + 1) % 2, tedad = 0;
  for (long long i = id1; i <= id2; i++) {
    cnt[a[i]]++;
    if (cnt[a[i]] % 2 == 1)
      tedad++;
    else
      tedad--;
  }
  if (tedad > rem) return cout << 0, 0;
  long long j2 = id2, j1 = id1, mid = (id1 + id2) / 2;
  while (j2 > mid) {
    if (cnt[a[j2]] <= 1) break;
    cnt[a[j2]] -= 2;
    j2--;
  }
  if (j2 == mid) {
    if (!(rem and cnt[a[j2]] != 1)) {
      j2 = (id1 + id2 - 1) / 2;
      while (j2 >= id1 and a[j2] == a[n - 1 - j2]) j2--;
    }
  }
  fill(cnt, cnt + n + 10, 0);
  for (long long i = id1; i <= id2; i++) cnt[a[i]]++;
  mid = (id1 + id2 + 1) / 2;
  while (j1 < mid) {
    if (cnt[a[j1]] <= 1) break;
    cnt[a[j1]] -= 2;
    j1++;
  }
  if (j1 == mid) {
    if (!(rem and cnt[a[j1]] != 1)) {
      j1 = mid + rem;
      while (j1 <= id2 and a[j1] == a[n - 1 - j1]) j1++;
    }
  }
  long long ans = 1ll * (id1 + 1) * (n - j2) + 1ll * (j1 - id1) * (n - id2);
  cout << ans << endl;
  return 0;
}
