#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
int n, o;
int A[MAXN], cnt[MAXN];
int cnt_temp[MAXN];
bool can_palindrome() {
  for (int i = 0, _n = n; i < _n; i++) cnt[A[i]]++;
  int odd = 0;
  for (int i = 0, _n = n + 1; i < _n; i++) odd += (cnt[i] % 2 == 1);
  return odd == o;
}
bool is_palindrome() {
  for (int i = 0, _n = n; i < _n; i++)
    if (A[i] != A[n - 1 - i]) return false;
  return true;
}
int main() {
  cin >> n;
  o = n % 2;
  for (int i = 0, _n = n; i < _n; i++) cin >> A[i];
  if (!can_palindrome()) {
    cout << 0 << endl;
    return 0;
  }
  if (is_palindrome()) {
    cout << 1LL * n * (n + 1) / 2 << endl;
    return 0;
  }
  int x = 0;
  while (A[x] == A[n - 1 - x]) x++;
  long long result = 0LL;
  for (int i = 0; i < x; i++) cnt[A[i]] -= 2;
  for (int i = 0, _n = n + 1; i < _n; i++) cnt_temp[i] = cnt[i];
  int y;
  for (y = n - 1 - x; y > x; y--) {
    if (n % 2 == 1 && y == n / 2) {
      if (cnt[A[y]] % 2 != 1) break;
    } else if (y >= n / 2) {
      cnt_temp[A[y]]--;
      if (cnt_temp[A[y]] < cnt[A[y]] / 2 + (cnt[A[y]] % 2 == 1)) break;
    } else {
      if (A[y] != A[n - 1 - y]) break;
    }
  }
  y = (n - y - 1);
  result += (1LL * (x + 1) * (y + 1));
  for (int i = 0, _n = n + 1; i < _n; i++) cnt_temp[i] = cnt[i];
  for (y = x; y < n; y++) {
    if (n % 2 == 1 && y == n / 2) {
      if (cnt[A[y]] % 2 != 1) break;
    } else if (y < n / 2) {
      cnt_temp[A[y]]--;
      if (cnt_temp[A[y]] < cnt[A[y]] / 2 + (cnt[A[y]] % 2 == 1)) break;
    } else {
      if (A[y] != A[n - 1 - y]) break;
    }
  }
  result += (1LL * (x + 1) * (y + 1));
  result -= 1LL * (x + 1) * (x + 1);
  cout << result << endl;
  return 0;
}
