#include <bits/stdc++.h>
using namespace std;
int N, T, P, Q;
int A[100005];
int cnt[100005], tmp[100005];
int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; i++) scanf("%d", A + i), cnt[A[i]]++;
  int odds = 0;
  for (int i = 1; i <= N; i++)
    if (cnt[i] & 1) odds++, T = i;
  if ((N & 1) != odds) {
    puts("0");
    return 0;
  }
  for (int i = 1; i <= N; i++) tmp[i] = cnt[i];
  for (int i = 1; i <= N; i++) {
    tmp[A[i]] -= 2;
    P = i;
    if (odds && i == (N + 1) / 2 && A[i] != T) break;
    if (i <= N / 2 && tmp[A[i]] < 0 || i > N / 2 && A[i] != A[N - i + 1]) break;
  }
  for (int i = 1; i <= N; i++) tmp[i] = cnt[i];
  for (int i = N; i; i--) {
    tmp[A[i]] -= 2;
    Q = i;
    if (odds && i == (N + 1) / 2 && A[i] != T) break;
    if (i > (N + 1) / 2 && tmp[A[i]] < 0 ||
        i <= (N + 1) / 2 && A[i] != A[N - i + 1])
      break;
  }
  long long ans = 0;
  for (int i = 0; i + 1 <= N - i; i++) {
    if (A[i] != A[N - i + 1]) break;
    ans += (min(N - i, P) - i) + (N - i + 1 - max(i + 1, Q)) - 1;
  }
  printf("%lld\n", ans);
}
