#include <bits/stdc++.h>
using namespace std;
int n, a[100005], num[100005], use[100005];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]), num[a[i]]++;
  int flag = 0, pos = 0;
  for (int i = 1; i <= n; i++) {
    if (num[i] % 2) {
      if (flag) {
        flag = 2;
        break;
      }
      flag = 1;
    }
  }
  if (flag == 2) {
    printf("%d\n", 0);
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    if (a[i] != a[n - i + 1]) {
      pos = i;
      break;
    }
    num[a[i]] -= 2;
  }
  if (!pos) {
    printf("%lld\n", (long long)n * (n + 1) >> 1);
    return 0;
  }
  int l = 0, r = 0;
  for (int i = pos; i <= n; i++) {
    use[a[i]]++;
    if (use[a[i]] * 2 > num[a[i]]) {
      if ((i < n - i + 1) || (i == n - i + 1 && (!num[a[i]] % 2)) ||
          (a[i] != a[n - i + 1]))
        break;
    }
    l++;
  }
  memset(use, 0, sizeof(use));
  for (int i = n - pos + 1; i >= 1; i--) {
    use[a[i]]++;
    if (use[a[i]] * 2 > num[a[i]]) {
      if (i > n - i + 1) break;
      if (i == n - i + 1)
        if (!(num[a[i]] % 2)) break;
      if (a[i] != a[n - i + 1]) break;
    }
    r++;
  }
  printf("%lld\n", (long long)(l + r + pos) * pos);
}
