#include <bits/stdc++.h>
using namespace std;
const int MAX = 110000;
int a[MAX];
int cnt[MAX];
bool con2pa(int cnt[], int n) {
  int odd = 0, i;
  for (i = 0; i <= n; i++) {
    if (cnt[i] & 1) odd++;
  }
  if (n & 1) return odd == 1;
  return odd == 0;
}
bool sidepa[MAX];
int side2pa[MAX];
int tcnt[MAX];
bool middle[MAX];
void getmiddle(int n, int midele) {
  int i, j;
  memset(middle, false, sizeof(bool) * (n + 2));
  if (n & 1) {
    i = n >> 1;
    j = n >> 1;
    if (a[i] != midele) return;
  } else {
    i = (n >> 1) - 1;
    j = i + 1;
  }
  while (i >= 0) {
    if (a[i] == a[j]) {
      middle[i] = middle[j] = true;
    } else
      break;
    i--;
    j++;
  }
}
void getsidepa(int n) {
  int i, j;
  for (i = 0; i < n; i++) sidepa[i] = false;
  i = 0;
  j = n - 1;
  while (i <= j) {
    if (a[i] == a[j]) {
      sidepa[i] = sidepa[j] = true;
    } else
      break;
    i++;
    j--;
  }
}
void getside2pa(int n) {
  int i, j;
  memset(side2pa, 0, sizeof(int) * n + 2);
  memset(tcnt, 0, sizeof(int) * (n + 2));
  int lim = n >> 1;
  for (i = n - 1; i >= 0; i--) {
    tcnt[a[i]]++;
    if (tcnt[a[i]] * 2 > cnt[a[i]]) break;
    side2pa[i] = true;
  }
  for (i = 1; i < n; i++) side2pa[i] += side2pa[i - 1];
  side2pa[n] = side2pa[n - 1];
}
long long calcspan(int n, int midele) {
  int midr = n >> 1;
  bool sideok = true;
  getside2pa(n);
  int i;
  int midl = n >> 1;
  int rlim = n - 1;
  long long ret = 0;
  if ((n & 1) == 0) midl--;
  for (i = 0; i <= midl; i++) {
    if (rlim >= midr) ret += side2pa[rlim] - side2pa[midr];
    if (a[i] != a[rlim]) sideok = false;
    if (!sideok) break;
    rlim--;
  }
  return ret;
}
long long calcside(int n, int oddele) {
  if ((n & 1) && a[n >> 1] != oddele) return 0;
  long long ret = 0;
  int i, j;
  bool sideflag = true;
  for (i = 0; i <= n; i++) tcnt[i] = 0;
  j = n >> 1;
  for (i = 0; i < j; i++) {
    tcnt[a[i]]++;
  }
  for (i = 0; i <= n; i++) {
    if (tcnt[i] * 2 != cnt[i]) return 0;
  }
  for (i = 0; i * 2 < n; i++) {
    if (middle[i]) break;
  }
  int midlim = i;
  int rside = n >> 1;
  rside--;
  for (i = 0; i <= rside; i++) {
    int l = midlim - 1;
    if (i > l) l = i;
    ret += rside - l + 1;
    if (a[i] != a[n - i - 1]) break;
  }
  return ret * 2;
}
int main() {
  int n, i, j;
  while (scanf("%d", &n) != EOF) {
    memset(cnt, 0, sizeof(int) * (n + 2));
    for (i = 0; i < n; i++) {
      scanf("%d", &a[i]);
      cnt[a[i]]++;
    }
    if (!con2pa(cnt, n)) {
      puts("0");
      continue;
    }
    int oddele = 0;
    for (i = 0; i <= n; i++) {
      if (cnt[i] & 1) {
        oddele = i;
        cnt[i]--;
        break;
      }
    }
    getsidepa(n);
    getmiddle(n, oddele);
    long long ans = 0;
    ans += calcside(n, oddele);
    ans += calcspan(n, oddele);
    reverse(a, a + n);
    ans += calcspan(n, oddele);
    for (i = 0, j = n - 1; i <= j; i++, j--) {
      ans++;
      if (a[i] != a[j]) break;
    }
    cout << ans << endl;
  }
  return 0;
}
