#include <bits/stdc++.h>
using namespace std;
int a[100005];
int dq, now;
long long ans;
bool flag;
int n, sum;
int s[100005];
bool check(int l, int r) {
  memset(s, 0, sizeof(s));
  for (int i = dq; i <= n - dq + 1; ++i) {
    if ((i < l || i > r) && (n - i + 1 < l || n - i + 1 > r) &&
        (a[i] != a[n - i + 1]))
      return false;
  }
  for (int i = l; i <= r; ++i) ++s[a[i]];
  for (int i = dq; i <= n - dq + 1; ++i) {
    if (i >= l && i <= r && (n - i + 1 < l || n - i + 1 > r)) {
      --s[a[n - i + 1]];
      if (s[a[n - i + 1]] < 0) return false;
    }
  }
  return true;
}
int work(int l, int r) {
  int ans, mid;
  while (l <= r) {
    mid = (l + r) / 2;
    if (check(dq, mid)) {
      ans = mid;
      r = mid - 1;
    } else
      l = mid + 1;
  }
  return ans;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  for (int i = 1; i <= n; ++i) ++s[a[i]];
  for (int i = 1; i <= n; ++i) sum += s[i] % 2;
  if (sum >= 2) {
    printf("0\n");
    return 0;
  }
  flag = true;
  for (int i = 1; i <= n; ++i)
    if (a[i] != a[n + 1 - i]) flag = false;
  if (flag) {
    ans = 1LL * n * (n + 1) / 2;
    printf("%I64d\n", ans);
    return 0;
  }
  for (dq = 1; a[dq] == a[n + 1 - dq]; ++dq)
    ;
  now = work(dq, n - dq + 1);
  ans = 1LL * dq * (n - now + 1);
  reverse(a + 1, a + n + 1);
  now = work(dq, n - dq + 1);
  ans += 1LL * dq * (n - dq - now + 1);
  printf("%I64d\n", ans);
  return 0;
}
