#include <bits/stdc++.h>
using namespace std;
long long int powmod(long long int a, int b, int n) {
  long long int rm = 1;
  while (b) {
    if (b % 2) {
      rm = (rm * a) % n;
    }
    a = (a * a) % n;
    b /= 2;
  }
  return rm;
}
int n, a[int(1e5 + 10)], ct[int(1e5 + 10)] = {0}, done[int(1e5 + 10)] = {0},
                                      sum1 = 0, sum2 = 0;
int main() {
  int st = 1, ed;
  cin >> n;
  for (int i = int(1); i <= (int)n; i++) {
    cin >> a[i];
    ct[a[i]]++;
  }
  int oo = 0;
  for (int i = 1; i <= n; ++i) {
    if (ct[i] % 2) oo++;
  }
  if (n % 2 != oo) {
    cout << 0 << endl;
    return 0;
  }
  for (; st <= n / 2 + n % 2; ++st) {
    if (a[st] != a[n - st + 1]) break;
    ct[a[st]] -= 2;
  }
  if (st > n / 2 + n % 2) {
    long long int ans = n;
    ans *= n + 1;
    ans /= 2;
    cout << ans << endl;
    return 0;
  }
  ed = n - st + 1;
  for (int i = st; i <= ed; ++i) {
    done[a[i]]++;
    if (ct[a[i]] % 2 == 1) {
      if (done[a[i]] == ct[a[i]] / 2 + 1) {
        if (i != n / 2 + 1) {
          break;
        }
      } else if (done[a[i]] <= ct[a[i]] / 2) {
      } else if (done[a[i]] > ct[a[i]] / 2 + 1) {
        if (a[i] == a[n - i + 1] && n - i + 1 < i) {
          sum1++;
          continue;
        } else
          break;
      }
    } else if (done[a[i]] > ct[a[i]] / 2) {
      if (n - i + 1 < i && a[i] == a[n - i + 1]) {
        sum1++;
        continue;
      } else
        break;
    }
    sum1++;
  }
  sum2 = 0;
  memset(done, 0, sizeof(done));
  ;
  for (int i = ed; i >= st; i--) {
    done[a[i]]++;
    if (ct[a[i]] % 2 == 1) {
      if (done[a[i]] == ct[a[i]] / 2 + 1) {
        if (i != n / 2 + 1) {
          break;
        }
      } else if (done[a[i]] <= ct[a[i]] / 2) {
      } else if (done[a[i]] > ct[a[i]] / 2 + 1) {
        if (a[i] == a[n - i + 1] && n - i + 1 > i) {
          sum2++;
          continue;
        } else
          break;
      }
    } else if (done[a[i]] > ct[a[i]] / 2) {
      if (n - i + 1 > i && a[i] == a[n - i + 1]) {
        sum2++;
        continue;
      } else
        break;
    }
    sum2++;
  }
  long long int anss;
  anss = (long long int)(st - 1 + 1) * (sum2 + st - 1 + 1) +
         sum1 * (long long int)(st - 1 + 1);
  cout << anss << endl;
  return 0;
}
