#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 10;
int a[maxn], b[maxn], oc[maxn], cnt[maxn];
int main() {
  int n;
  scanf("%d", &n);
  int odd = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", a + i);
    oc[a[i]] ^= 1;
    if (oc[a[i]] == 1)
      odd++;
    else
      odd--;
  }
  if (odd > 1) {
    printf("0\n");
    return 0;
  }
  int l = 1, r = n, m = 0;
  while (l < r) {
    if (a[l] == a[r]) {
      l++;
      r--;
    } else
      break;
  }
  if (l >= r) {
    printf("%I64d\n", (long long)n * (n + 1) / 2);
  } else {
    for (int i = l; i <= r; i++) b[m++] = a[i];
    auto solve = [&](int p) {
      memset(cnt, 0, sizeof(cnt));
      for (int i = 0; i <= p; i++) {
        cnt[b[i]]++;
      }
      for (int i = 0; i < (m + 1) / 2; i++) {
        int pr = m - i - 1;
        if (i > p) {
          if (b[i] != b[pr]) return 0;
        } else if (pr > p) {
          if (!cnt[b[pr]]) return 0;
          cnt[b[pr]]--;
        }
      }
      odd = 0;
      for (int i = 0; i <= n; i++)
        if (cnt[i] % 2) odd++;
      if (odd > 1) return 0;
      return 1;
    };
    l = 0, r = m - 1;
    while (l < r) {
      int mid = (l + r) / 2;
      if (solve(mid))
        r = mid;
      else
        l = mid + 1;
    }
    int pref = l + 1;
    reverse(b, b + m);
    l = 0, r = m - 1;
    while (l < r) {
      int mid = (l + r) / 2;
      if (solve(mid))
        r = mid;
      else
        l = mid + 1;
    }
    int suff = l + 1;
    printf("%I64d\n", (long long)((n - m) / 2 + 1) *
                          ((n - m) / 2 + 2 * m + 1 - pref - suff));
  }
}
