#include <bits/stdc++.h>
using namespace std;
long long A[100005], C[100005], D[100005];
int main() {
  long long n;
  scanf("%I64d", &n);
  for (long long i = 1; i <= n; i++) {
    scanf("%I64d", &A[i]);
    C[A[i]]++;
  }
  int flag = 0;
  for (long long i = 1; i <= n; i++) {
    if (C[i] % 2 == 1 && flag == 1) {
      printf("0\n");
      return 0;
    } else if (C[i] % 2 == 1)
      flag = 1;
  }
  if (flag == 1 && n % 2 == 0) {
    printf("0\n");
    return 0;
  }
  long long i = 1, j, k, l;
  while (A[i] == A[n - i + 1]) {
    C[A[i]] -= 2;
    long long ans = n * (n + 1) / 2;
    if (i > (n - i + 1)) {
      printf("%I64d\n", ans);
      return 0;
    }
    i++;
  }
  j = n - i + 1;
  k = i;
  l = j;
  for (int m = 1; m <= n; m++) D[m] = C[m];
  while (1) {
    if (C[A[j]] % 2 == 1 && (n + 1) / 2 == j) {
      C[A[j]]--;
      j--;
    } else if (C[A[j]] > 1) {
      C[A[j]] -= 2;
      j--;
    } else if (A[j] == A[n - j + 1] && (n - j + 1) > j)
      j--;
    else
      break;
  }
  while (1) {
    if (D[A[k]] % 2 == 1 && (n + 1) / 2 == k) {
      D[A[k]]--;
      k++;
    } else if (D[A[k]] > 1) {
      D[A[k]] -= 2;
      k++;
    } else if (A[k] == A[n - k + 1] && (n - k + 1) < k)
      k++;
    else
      break;
  }
  long long ans = i * (n - j + 1) + k * (n - l + 1) - i * (n - l + 1);
  printf("%I64d\n", ans);
  return 0;
}
