#include <bits/stdc++.h>
using std::cin;
using std::cout;
const long long N = 100007;
long long n, f[N], a[N], _[N];
signed main() {
  std::ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  for (long long i = 1; i <= n; ++i) {
    cin >> a[i];
    ++f[a[i]];
  }
  long long tot = 0;
  for (long long i = 1; i <= n; ++i)
    if (f[i] & 1) ++tot;
  if (tot > 1)
    cout << "0\n";
  else {
    long long pos = 0;
    for (long long i = 1; i <= n; ++i) {
      if (a[i] ^ a[n - i + 1]) {
        pos = i;
        break;
      } else
        f[a[i]] -= 2;
    }
    if (pos == 0)
      cout << (n + 1) * n / 2 << '\n';
    else {
      long long cnt = 0;
      for (long long i = pos; i <= n; ++i) {
        ++_[a[i]];
        if (_[a[i]] * 2 > f[a[i]])
          if (i < n - i + 1 || (i == n - i + 1 && f[a[i]] % 2 == 0) ||
              (a[i] ^ a[n - i + 1]))
            break;
        ++cnt;
      }
      memset(_, 0, sizeof(_));
      for (long long i = n - pos + 1; i >= 1; --i) {
        ++_[a[i]];
        if (_[a[i]] * 2 > f[a[i]])
          if (i > n - i + 1 || (i == n - i + 1 && f[a[i]] % 2 == 0) ||
              (a[i] ^ a[n - i + 1]))
            break;
        ++cnt;
      }
      cout << (pos * pos) + (pos * cnt) << '\n';
    }
  }
  return 0;
}
