#include <bits/stdc++.h>
int a[100005], b[100005], c[100005];
int main(void) {
  int odd = 0, i, n, k;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    b[a[i]]++;
    if (b[a[i]] % 2 == 1)
      odd++;
    else
      odd--;
  }
  if (odd > 1) {
    printf("0");
    return 0;
  }
  int start, end;
  for (i = 0; i < n / 2; i++) {
    if (a[i] != a[n - 1 - i]) break;
    b[a[i]] -= 2;
  }
  start = i;
  end = n - i - 1;
  if (start == n / 2) {
    printf("%lld", (long long)n * (n + 1) / 2);
    return 0;
  }
  long long int count = 0;
  for (i = start; i < end; i++) {
    if (i < n / 2) {
      c[a[i]]++;
      if (c[a[i]] <= b[a[i]] / 2)
        count++;
      else
        break;
    } else {
      if (a[i] == a[n - i - 1])
        count++;
      else
        break;
    }
  }
  for (i = 1; i <= n; i++) c[i] = 0;
  for (i = end; i > start; i--) {
    if (i > n / 2 || (i == n / 2 && n % 2 == 0)) {
      c[a[i]]++;
      if (c[a[i]] <= b[a[i]] / 2)
        count++;
      else
        break;
    } else {
      if (a[i] == a[n - i - 1] && (n % 2 == 0 || b[a[i]] % 2))
        count++;
      else
        break;
    }
  }
  count *= (long long)(start + 1);
  count += (long long)(start + 1) * (start + 1);
  printf("%I64d", count);
  return 0;
}
