#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const int maxN = 100001;
int lf = 0, rt = 0;
int mcnt = 0;
int neg = 0;
int ttl = 0;
int n;
int a[maxN];
int diff[maxN];
int sgn(int val) { return (val > 0) - (val < 0); }
void remove_left() {
  if (lf >= n - 1)
    ++lf;
  else {
    int opp = n - 1 - lf;
    set<int> S({a[opp], a[lf]});
    for (int v : S) neg -= diff[v] > 0;
    ++diff[a[lf]];
    if (opp != lf) {
      if (opp < lf || opp > rt) {
        if (a[lf] != a[opp]) ++mcnt;
        --diff[a[opp]];
      } else
        ++diff[a[lf]];
    }
    for (int v : S) neg += diff[v] > 0;
    ++lf;
  }
}
void add_right() {
  if (rt >= n - 1)
    ++rt;
  else {
    ++rt;
    int opp = n - 1 - rt;
    set<int> S({a[opp], a[rt]});
    for (int v : S) neg -= diff[v] > 0;
    --diff[a[rt]];
    if (opp != rt) {
      if (opp < lf || opp > rt) {
        if (a[rt] != a[opp]) --mcnt;
        ++diff[a[opp]];
      } else
        --diff[a[rt]];
    }
    for (int v : S) neg += diff[v] > 0;
  }
}
int main() {
  cin >> n;
  int cnt[n + 1];
  memset(cnt, 0, sizeof(cnt));
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    ++cnt[a[i]];
  }
  int sum = 0;
  for (int i = 1; i <= n; ++i) sum += cnt[i] % 2;
  if (sum > 1) {
    cout << 0 << endl;
    return 0;
  }
  if (n == 1) {
    cout << 1 << endl;
    return 0;
  }
  memset(diff, 0, sizeof(diff));
  diff[a[0]]--;
  diff[a[n - 1]]++;
  neg = (a[0] != a[n - 1]);
  for (int i = 1; i < n / 2; ++i) mcnt += (a[i] != a[n - 1 - i]);
  long long res = 0;
  while (lf < n) {
    if (rt == n) break;
    if (rt < lf)
      add_right();
    else if (mcnt)
      add_right();
    else if (neg)
      add_right();
    else {
      res += n - rt;
      remove_left();
    }
  }
  cout << res << endl;
  return 0;
}
