#include <bits/stdc++.h>
using namespace std;
int n;
int datos[100005], freq[100005] = {0};
bool equal() {
  for (int i = 0; i < (int)(n); i++) {
    if (datos[i] != datos[n - i - 1]) return 0;
  }
  return 1;
}
bool pos(int l, int r) {
  memset(freq, 0, sizeof(freq));
  for (int i = l; i < (int)(r + 1); i++) freq[datos[i]]++;
  for (int i = l; i < (int)(r + 1); i++) {
    if (n - i - 1 < l || n - i - 1 > r) freq[datos[n - i - 1]]--;
  }
  int conta = 0;
  for (int i = 0; i < (int)(100005); i++) {
    if (freq[i] < 0) return 0;
    if (freq[i] % 2) conta++;
  }
  for (int i = 0; i < (int)(n); i++) {
    if ((i < l || i > r) && (n - i - 1 > r || n - i - 1 < l)) {
      if (datos[i] != datos[n - i - 1]) return 0;
    }
  }
  if (conta > 1) return 0;
  return 1;
}
int main() {
  cin >> n;
  map<int, int> freq;
  int conta = 0;
  for (int i = 0; i < (int)(n); i++) {
    cin >> datos[i];
    freq[datos[i]]++;
  }
  for (int i = 0; i < (int)(100005); i++)
    if (freq[i] % 2) conta++;
  if (conta > 1) {
    cout << 0 << endl;
    return 0;
  }
  if (equal()) {
    cout << ((long long)n * (long long)(n + 1)) / 2 << endl;
    return 0;
  }
  int l = 0, r = n - 1;
  while (1) {
    if (datos[l] != datos[r]) break;
    l++;
    r--;
  }
  int ini = l, fin = r, mid;
  while (fin - ini > 1) {
    mid = (ini + fin) / 2;
    if (pos(l, mid))
      fin = mid;
    else
      ini = mid;
  }
  int x = fin - l + 1;
  ini = l;
  fin = r;
  while (fin - ini > 1) {
    mid = (ini + fin) / 2;
    if (pos(mid, r))
      ini = mid;
    else
      fin = mid;
  }
  int y = r - ini + 1;
  int m = r - l + 1;
  long long sol =
      (long long)(((n - m) / 2 + 1) * (((n - m) / 2 + 2 * m + 1 - x - y)));
  cout << sol << endl;
  return 0;
}
