#include <bits/stdc++.h>
using namespace std;
using namespace std;
int n, lewy, prawy, sr, nparz, len;
int t[100100];
long long wynik = 0;
int obsluz(int x) {
  map<int, int> Map;
  for (int i = 1; i <= n; i++) Map[t[i]]++;
  if (x == 1)
    for (int i = 1; i <= n; i++) {
      Map[t[i]] -= 2;
      if (Map[t[i]] < 0) return --i;
    }
  else
    for (int i = n; i > 0; i--) {
      Map[t[i]] -= 2;
      if (Map[t[i]] < 0) return ++i;
    }
  return 0;
}
void licz() {
  for (int i = 1; i <= lewy; ++i) {
    wynik += lewy - i + 1;
    if (t[i] != t[n - i + 1]) break;
  }
  for (int i = n; i >= prawy; i--) {
    wynik += i - prawy + 1;
    if (t[i] != t[n - i + 1]) break;
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &t[i]);
  if (n == 1) {
    puts("1");
    return 0;
  }
  map<int, int> Map;
  for (int i = 1; i <= n; i++) Map[t[i]]++;
  int totalOdd = 0, nparz;
  for (map<int, int>::iterator it = Map.begin(); it != Map.end(); it++)
    if ((*it).second % 2 == 1) {
      totalOdd++;
      nparz = (*it).first;
    }
  lewy = obsluz(1), prawy = obsluz(2);
  sr = n / 2;
  if (totalOdd > 1) {
    puts("0");
    return 0;
  }
  for (int i = 1; i <= sr; i++) {
    wynik++;
    if (t[i] != t[n - i + 1]) break;
    if (i == sr && totalOdd == 1 && t[n / 2 + 1] == nparz) wynik++;
  }
  while (len <= n / 2 && t[len + 1] == t[n - len]) len++;
  if (lewy == n / 2 && (totalOdd == 0 || t[n / 2 + 1] == nparz))
    for (int i = n / 2 + 1; t[i] == t[n - i + 1] && i <= n; i++)
      wynik += min(len + 1, n - i);
  if (prawy == n - n / 2 + 1 && (totalOdd == 0 || t[n / 2 + 1] == nparz))
    for (int i = n - n / 2; t[i] == t[n - i + 1] && i > 0; i--)
      wynik += min(len + 1, i - 1);
  licz();
  printf("%I64d", wynik);
}
