#include <bits/stdc++.h>
using namespace std;
int n;
int num[100005];
bool pal_from[100005], col_nz[100005], col_neg[100005];
int f[100005], odd, not_z, neg;
long long ans;
bool is_pal_from(int ci) { return num[ci] == num[n - ci - 1]; }
void check_odd(int cnum) {
  if (abs(f[cnum]) % 2 == 1) odd++;
  if (abs(f[cnum]) % 2 == 0) odd--;
}
void check_nzero(int cnum) {
  if (f[cnum] != 0 && !col_nz[cnum]) not_z++;
  col_nz[cnum] = true;
  if (f[cnum] == 0) {
    not_z--;
    col_nz[cnum] = false;
  }
}
void check_neg(int cnum) {
  if (f[cnum] < 0 && !col_neg[cnum]) {
    neg++;
    col_neg[cnum] = true;
  }
  if (f[cnum] >= 0 && col_neg[cnum]) {
    neg--;
    col_neg[cnum] = false;
  }
}
void cal(int s) {
  for (int i = s; i < n - s; i++) {
    if (i < n - i - 1) {
      if (num[i] == num[n - i - 1]) continue;
      f[num[i]]++;
      f[num[n - i - 1]]--;
      check_odd(num[i]);
      check_odd(num[n - i - 1]);
      check_nzero(num[i]);
      check_nzero(num[n - 1 - i]);
      check_neg(num[i]);
      check_neg(num[n - 1 - i]);
      if (not_z == 0 && (n - i - 1 - i == 1 || (pal_from[i + 1]))) {
        ans += (long long)(s + 1) * (long long)(n - i);
        break;
      }
    } else {
      if (i == n - i - 1) {
        f[num[i]] += 1;
        check_odd(num[i]);
      } else
        f[num[i]] += 2;
      check_neg(num[i]);
      if (neg == 0 && odd <= 1) {
        ans += (long long)(s + 1) * (long long)(n - i);
        break;
      }
    }
  }
}
int main() {
  cin >> n;
  for (int i = 0; i < (n); ++i) cin >> num[i];
  for (int i = n / 2; i >= 0; i--)
    if (!is_pal_from(i))
      break;
    else
      pal_from[i] = true;
  if (pal_from[0]) {
    ans = n;
    ans = ans * (ans + 1) / 2;
    cout << ans << endl;
    return 0;
  }
  int s = -1;
  for (int i = 0; i < n; i++)
    if (num[i] != num[n - i - 1]) {
      s = i;
      break;
    }
  cal(s);
  for (int i = 0; i < n / 2; i++) swap(num[i], num[n - i - 1]);
  odd = not_z = neg = 0;
  for (int i = 0; i < 100005; i++) {
    col_neg[i] = col_nz[i] = false;
    f[i] = 0;
  }
  cal(s);
  if (ans > 0) {
    ans -= (long long)(s + 1) * (long long)(s + 1);
  }
  cout << ans << endl;
  return 0;
}
