#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int n;
int a[maxn];
bool eq[maxn];
int cnt[maxn], tmp[maxn];
int main() {
  while (scanf("%d", &n) != EOF) {
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    int odd = 0;
    memset(cnt, 0, sizeof(cnt));
    for (int i = 1; i <= n; i++) cnt[a[i]]++;
    for (int i = 1; i <= n; i++)
      if (cnt[i] & 1) {
        odd++;
      }
    if (odd > 1 || (odd == 1 && n % 2 == 0)) {
      printf("0\n");
      continue;
    } else {
      int l = 1, r;
      while (l <= n && a[l] == a[n - l + 1]) l++;
      if (l > n) {
        printf("%I64d\n", (long long)n * (n + 1) / 2);
        continue;
      }
      r = n + 1 - l;
      long long ans = 0, sum = 0;
      for (int i = 1; i <= n; i++) tmp[i] = cnt[i], sum += cnt[i];
      ;
      for (int i = 1; i <= r - 1; i++) {
        ans += l;
        if (cnt[a[i]] >= 2) {
          cnt[a[i]] -= 2;
          sum -= 2;
        } else if (cnt[a[i]] == 1) {
          cnt[a[i]]--;
          sum--;
          if (i != n + 1 - i) {
            break;
          }
        } else {
          if (a[i] != a[n + 1 - i]) break;
          if (sum > 0) break;
        }
      }
      for (int i = 1; i <= n; i++) cnt[i] = tmp[i], sum += tmp[i];
      for (int i = n; i >= l + 1; i--) {
        ans += l;
        if (cnt[a[i]] >= 2) {
          cnt[a[i]] -= 2;
          sum -= 2;
        } else if (cnt[a[i]] == 1) {
          cnt[a[i]]--;
          sum--;
          if (i != n + 1 - i) {
            break;
          }
        } else {
          if (a[i] != a[n + 1 - i]) break;
          if (sum > 0) break;
        }
      }
      ans -= (long long)l * l;
      printf("%I64d\n", ans);
    }
  }
  return 0;
}
