#include <bits/stdc++.h>
using namespace std;
int n, i, a[100010], gs[100010], ss, j, cd, cd2, gs1[100010], tt;
long long ans;
int main() {
  scanf("%d", &n);
  for (i = 1; i <= n; i++) scanf("%d", &a[i]), gs[a[i]]++;
  for (i = 1; i <= n; i++) ss += gs[i] & 1, tt += (gs[i] & 1) * i;
  if (ss > 1) return puts("0"), 0;
  for (i = 1; i * 2 <= n && a[i] == a[n - i + 1]; i++)
    ;
  cd = i - 1;
  if (i * 2 > n) return printf("%I64d\n", 1ll * n * (n + 1) / 2), 0;
  for (i = (n + 1) >> 1; i >= 1 && a[i] == a[n - i + 1]; i--)
    ;
  cd2 = i + 1;
  for (i = 1; i <= n / 2 && (++gs1[a[i]]) * 2 <= gs[a[i]]; i++)
    ;
  memset(gs1, 0, sizeof(gs1));
  i--;
  for (j = n; j > (n + 1) / 2 && (++gs1[a[j]]) * 2 <= gs[a[j]]; j--)
    ;
  j++;
  ans = 1ll * (cd + 1) * (cd + 1);
  if (i >= n / 2 && (a[(n + 1) >> 1] == tt || (!tt)))
    ans += 1ll * (n - cd2 + 1 - cd) * (cd + 1);
  else
    ans += 1ll * (i - cd) * (cd + 1);
  if (j <= (n + 1) / 2 + 1 && (a[(n + 1) >> 1] == tt || (!tt)))
    ans += 1ll * (n - cd2 + 1 - cd) * (cd + 1);
  else
    ans += 1ll * (n - j + 1 - cd) * (cd + 1);
  printf("%I64d\n", ans);
}
