#include <bits/stdc++.h>
const int maxN = 100005;
int book[maxN] = {0}, sumOdd = {0}, num[maxN], count[maxN] = {0}, ans = 0;
int main() {
  int n;
  scanf("%d", &n);
  int l = 1, r = n;
  double mid = (1.0 + n) / 2;
  for (int i = 1; i <= n; i++) {
    scanf("%d", num + i);
    book[num[i]]++;
    if (book[num[i]] % 2)
      sumOdd++;
    else
      sumOdd--;
  }
  if (sumOdd > 1) {
    printf("0\n");
    return 0;
  }
  while (num[l] == num[r] && l <= r) {
    book[num[l]] -= 2;
    l++;
    r--;
  }
  if (l > r)
    printf("%I64d\n", (long long)(1 + n) * n / 2);
  else {
    for (int i = l; l <= r; i++) {
      if (i < mid) {
        count[num[i]]++;
        if (count[num[i]] <= book[num[i]] / 2)
          ans++;
        else
          break;
      } else if (i == mid) {
        if (book[num[i]] % 2)
          ans++;
        else
          break;
      } else {
        if (num[i] == num[n + 1 - i])
          ans++;
        else
          break;
      }
    }
    memset(count, 0, sizeof(count));
    for (int i = r; i >= l; i--) {
      if (i > mid) {
        count[num[i]]++;
        if (count[num[i]] <= book[num[i]] / 2)
          ans++;
        else
          break;
      } else if (i == mid) {
        if (book[num[i]] % 2)
          ans++;
        else
          break;
      } else {
        if (num[i] == num[n + 1 - i])
          ans++;
        else
          break;
      }
    }
    printf("%I64d\n", (long long)l * (l + ans));
  }
  return 0;
}
