#include <bits/stdc++.h>
using namespace std;
const int maxn = 100007;
int n;
int a[maxn];
int calcL() {
  map<int, int> Map;
  for (int i = 1; i <= n; i++) {
    Map[a[i]]++;
  }
  for (int i = 1; i <= n; i++) {
    Map[a[i]] -= 2;
    if (Map[a[i]] < 0) return i - 1;
  }
  while (1)
    ;
}
int calcR() {
  map<int, int> Map;
  for (int i = 1; i <= n; i++) {
    Map[a[i]]++;
  }
  for (int i = n; i >= 1; i--) {
    Map[a[i]] -= 2;
    if (Map[a[i]] < 0) return i + 1;
  }
  while (1)
    ;
}
long long solve() {
  if (n == 1) return 1;
  map<int, int> Map;
  for (int i = 1; i <= n; i++) {
    Map[a[i]]++;
  }
  int totalOdd = 0, oddNum;
  for (map<int, int>::iterator it = Map.begin(); it != Map.end(); it++) {
    if (it->second & 1) {
      totalOdd++;
      oddNum = it->first;
    }
  }
  if (totalOdd > 1) return 0;
  int L = calcL(), R = calcR(), mid = n / 2;
  long long res = 0;
  for (int i = 1; i <= mid; i++) {
    res++;
    if (a[i] != a[n - i + 1]) break;
    if (i == mid && totalOdd == 1 && a[n / 2 + 1] == oddNum) {
      res++;
    }
  }
  int len = 0;
  while (len <= n / 2 && a[len + 1] == a[n - len]) len++;
  if (L == n / 2 && (totalOdd == 0 || a[n / 2 + 1] == oddNum)) {
    for (int i = n / 2 + 1; a[i] == a[n - i + 1] && i <= n; i++) {
      res += min(len + 1, n - i);
    }
  }
  if (R == n - n / 2 + 1 && (totalOdd == 0 || a[n / 2 + 1] == oddNum)) {
    for (int i = n - n / 2; a[i] == a[n - i + 1] && i > 0; i--) {
      res += min(len + 1, i - 1);
    }
  }
  for (int i = 1; i <= L; i++) {
    res += L - i + 1;
    if (a[i] != a[n - i + 1]) break;
  }
  for (int i = n; i >= R; i--) {
    res += i - R + 1;
    if (a[i] != a[n - i + 1]) break;
  }
  return res;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  cout << solve() << endl;
  return 0;
}
