#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int a[N];
int n;
map<int, int> cnt;
int bad;
void add(int i) {
  int x = a[i];
  if (++cnt[x] == 1) ++bad;
}
void remove(int i) {
  int x = a[i];
  if (--cnt[x] == 0) --bad;
}
int solve(int x, int y) {
  int l = x, r = n - 1 - x;
  cnt.clear();
  bad = 0;
  int ans = 0;
  for (int i = l; i < r; ++i) {
    remove(i);
    if (i < n - 1 - i) add(n - 1 - i);
    if (i > n - 1 - i) remove(i);
    if (i >= y && bad == 0) ++ans;
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int _n(n), i(0); i < _n; i++) cin >> a[i];
  map<int, int> cnt;
  for (int _n(n), i(0); i < _n; i++) {
    cnt[a[i]]++;
  }
  int odd = 0;
  for (auto el : cnt) {
    if (el.second & 1) ++odd;
  }
  if (odd > 1) {
    cout << 0 << endl;
    return 0;
  }
  int x = 0, y = (n + 1) / 2 - 1;
  while (x < n && a[x] == a[n - 1 - x]) ++x;
  while (0 <= y && a[y] == a[n - 1 - y]) --y;
  if (x >= n) {
    cout << n * 1ll * (n + 1) / 2 << endl;
    return 0;
  }
  int c1 = solve(x, y);
  reverse(a, a + n);
  int c2 = solve(x, y);
  cout << (x + 1) * 1ll * (x + 1 + c1 + c2) << endl;
  return 0;
}
