#include <bits/stdc++.h>
using namespace std;
long long int n;
int a[1000000];
int aparece[1000000];
int ocurrencias[1000000];
void reset() {
  for (int i = 1; i <= n; i++) aparece[i] = 0;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) ocurrencias[a[i]]++;
  int aimpar = 0;
  for (int i = 1; i <= n; i++) {
    if (ocurrencias[i] % 2 == 1) {
      if (aimpar) {
        cout << 0 << endl;
        exit(0);
      }
      aimpar = i;
    }
  }
  long long int if1 = 1;
  while (if1 <= n / 2 and a[if1] == a[n - if1 + 1]) if1++;
  if (if1 == n / 2 + 1) {
    cout << n * (n + 1) / 2 << endl;
    exit(0);
  }
  if (n % 2 == 0 or aimpar == a[n / 2 + 1]) {
    long long int if2 = n / 2;
    while (if2 > if1 and a[if2] == a[n - if2 + 1]) if2--;
    for (int i = if1; i <= if2; i++) {
      aparece[a[i]]++;
      aparece[a[n - i + 1]]--;
    }
    bool error = false;
    for (int i = 1; i <= n and not error; i++) error = aparece[i] != 0;
    if (not error) {
      cout << 2 * if1 * (n - if2 + 1) - if1 * if1 << endl;
      exit(0);
    }
    reset();
  }
  long long int sol = -if1 * if1;
  {
    for (int i = if1; i <= n / 2; i++) {
      aparece[a[i]]++;
      aparece[a[n - i + 1]]--;
    }
    int if2 = n / 2;
    if (n % 2 == 1) {
      aparece[a[n / 2 + 1]]++;
      if2++;
    }
    int nummenor = 0;
    for (int i = 1; i <= n; i++) nummenor += aparece[i] < 0;
    while (nummenor) {
      if2++;
      nummenor -= aparece[a[if2]] < 0;
      aparece[a[if2]] += 2;
      nummenor += aparece[a[if2]] < 0;
    }
    sol += if1 * (n - if2 + 1);
    reset();
  }
  for (int i = if1; i <= n / 2; i++) {
    aparece[a[i]]++;
    aparece[a[n - i + 1]]--;
  }
  int if2 = n / 2;
  if (n % 2 == 1) {
    aparece[a[n / 2 + 1]]--;
    if2++;
  }
  int nummayor = 0;
  for (int i = 1; i <= n; i++) nummayor += aparece[i] > 0;
  while (nummayor) {
    if2++;
    nummayor -= aparece[a[n - if2 + 1]] > 0;
    aparece[a[n - if2 + 1]] -= 2;
    nummayor += aparece[a[n - if2 + 1]] > 0;
  }
  sol += if1 * (n - if2 + 1);
  cout << sol << endl;
}
