#include <bits/stdc++.h>
using namespace std;
long long a[100005], b[100005], c[100005], sum;
int main() {
  long long n;
  long long tot = 0;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    b[a[i]]++;
    if (b[a[i]] & 1)
      tot++;
    else
      tot--;
  }
  if (tot > 1) {
    cout << 0 << endl;
    return 0;
  }
  long long i;
  for (i = 0; i < n / 2; i++) {
    if (a[i] == a[n - 1 - i])
      b[a[i]] -= 2;
    else
      break;
  }
  if (i == n / 2) {
    cout << n * (n + 1) / 2 << endl;
    return 0;
  }
  long long l = i, r = n - 1 - i;
  long long left = r;
  memset(c, 0, sizeof(c));
  for (; left >= l; left--) {
    c[a[left]]++;
    if (c[a[left]] * 2 > b[a[left]]) {
      if (left > ((n - 1) >> 1)) break;
      if (a[left] != a[n - 1 - left]) break;
      if (!(b[a[left]] & 1) && left == n - 1 - left) break;
    }
  }
  sum = 0;
  sum += (l + 1) * (r - left);
  long long right = l;
  memset(c, 0, sizeof(c));
  for (; right <= r; right++) {
    c[a[right]]++;
    if (c[a[right]] * 2 > b[a[right]]) {
      if (right < ((n - 1) >> 1)) break;
      if (a[right] != a[n - 1 - right]) break;
      if (!(b[a[right]] & 1) && right == n - 1 - right) break;
    }
  }
  sum += (n - r) * (right - l);
  sum += (l + 1) * (n - r);
  cout << sum << endl;
  return 0;
}
