#include <bits/stdc++.h>
using namespace std;
int n;
int a[100000];
int deg[100000] = {}, cur[100000];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < (int)(n); ++i) scanf("%d", a + i), --a[i];
  bool ok = true;
  for (int i = 0; i < (int)(n); ++i)
    if (a[i] != a[n - 1 - i]) {
      ok = false;
      break;
    }
  if (ok) {
    cout << (long long)n * (n + 1) / 2 << endl;
    return 0;
  }
  for (int i = 0; i < (int)(n); ++i) ++deg[a[i]];
  long long ans = 0;
  if (n & 1) {
    int o = -1;
    for (int i = 0; i < (int)(n); ++i)
      if (deg[i] & 1) {
        if (o != -1) {
          printf("0\n");
          return 0;
        }
        o = i;
      }
    if (o == -1) {
      printf("0\n");
      return 0;
    }
    int lo = 0;
    while (lo < n / 2 && a[lo] == a[n - 1 - lo]) ++lo;
    ans = (long long)(lo + 1) * (lo + 1);
    for (int i = 0; i < (int)(n); ++i) deg[i] = (deg[i] + 1) / 2;
    int bad = 0;
    for (int i = 0; i < (int)(n); ++i) {
      cur[i] = 0;
      if (deg[i]) ++bad;
    }
    int i = 0;
    while (bad) {
      if (++cur[a[i]] == deg[a[i]]) {
        --bad;
      }
      ++i;
    }
    if (i == (n + 1) / 2 && a[i - 1] == o) {
      while (a[i - 1] == a[n - i]) --i;
    }
    ans += (long long)(lo + 1) * (n - lo - i);
    bad = 0;
    for (int i = 0; i < (int)(n); ++i) {
      cur[i] = 0;
      if (deg[i]) ++bad;
    }
    i = n - 1;
    while (bad) {
      if (++cur[a[i]] == deg[a[i]]) {
        --bad;
      }
      --i;
    }
    if (i == n / 2 - 1 && a[i + 1] == o) {
      while (a[i + 1] == a[n - i - 2]) ++i;
    }
    ans += (long long)(lo + 1) * (i - lo + 1);
  } else {
    for (int i = 0; i < (int)(n); ++i)
      if (deg[i] & 1) {
        printf("0\n");
        return 0;
      }
    int lo = 0;
    while (lo < n / 2 && a[lo] == a[n - 1 - lo]) ++lo;
    ans = (long long)(lo + 1) * (lo + 1);
    for (int i = 0; i < (int)(n); ++i) deg[i] /= 2;
    int bad = 0;
    for (int i = 0; i < (int)(n); ++i) {
      cur[i] = 0;
      if (deg[i]) ++bad;
    }
    int i = 0;
    while (bad) {
      if (++cur[a[i]] == deg[a[i]]) {
        --bad;
      }
      ++i;
    }
    if (i == n / 2) {
      while (a[i - 1] == a[n - i]) --i;
    }
    ans += (long long)(lo + 1) * (n - lo - i);
    bad = 0;
    for (int i = 0; i < (int)(n); ++i) {
      cur[i] = 0;
      if (deg[i]) ++bad;
    }
    i = n - 1;
    while (bad) {
      if (++cur[a[i]] == deg[a[i]]) {
        --bad;
      }
      --i;
    }
    if (i == n / 2 - 1) {
      while (a[i + 1] == a[n - i - 2]) ++i;
    }
    ans += (long long)(lo + 1) * (i - lo + 1);
  }
  cout << ans << endl;
  return 0;
}
