#include <bits/stdc++.h>
using namespace std;
#pragma warning(disable : 4996)
long long n, a[100001], i, b[100001], c[100001];
int main() {
  scanf("%I64d", &n);
  for (i = 1; i <= n; i++) {
    scanf("%I64d", &a[i]);
    b[a[i]]++;
  }
  bool flag = 0;
  for (i = 1; i <= n; i++)
    if (b[i] % 2 == 1) {
      if (flag) {
        printf("0\n");
        return 0;
      } else
        flag = 1;
    }
  if (flag && (n % 2 == 0)) {
    printf("0\n");
    return 0;
  }
  i = 1;
  long long ans = n * (n + 1) / 2;
  while (a[i] == a[n - i + 1]) {
    b[a[i]] -= 2;
    if (i > n - i + 1) {
      printf("%I64d\n", ans);
      return 0;
    }
    i++;
  }
  long long j = n - i + 1, k = i, l = j;
  memcpy(c, b, sizeof c);
  while (1) {
    if (b[a[j]] % 2 == 1 && (j == (n + 1) / 2))
      b[a[j]]--;
    else if (b[a[j]] > 1)
      b[a[j]] -= 2;
    else if (a[j] == a[n - j + 1] && j < n - j + 1)
      ;
    else
      break;
    j--;
  }
  while (1) {
    if (c[a[k]] % 2 == 1 && (k == (n + 1) / 2))
      c[a[k]]--;
    else if (c[a[k]] > 1)
      c[a[k]] -= 2;
    else if (a[k] == a[n - k + 1] && (n - k + 1) < k)
      ;
    else
      break;
    k++;
  }
  ans = i * (n - j + 1) + k * (n - l + 1) - i * (n - l + 1);
  printf("%I64d\n", ans);
  return 0;
}
