#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
void ckmin(T &a, U b) {
  if (a > b) a = b;
}
template <class T, class U>
void ckmax(T &a, U b) {
  if (a < b) a = b;
}
int N;
int arr[100013];
vector<int> pos[100013];
bitset<100013> bad, bad1;
long long ans;
int delta[100013], bads;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> N;
  for (auto i = (0); i < (N); i++) {
    cin >> arr[i];
    arr[i]--;
    delta[arr[i]]++;
  }
  int nums = 0;
  for (auto i = (0); i < (N); i++) {
    if (delta[i] & 1) nums++;
  }
  if (nums >= 2) {
    cout << "0\n";
    return 0;
  }
  for (auto i = (0); i < (N); i++) delta[i] = 0;
  for (auto i = (((N + 1) / 2) - 1); i >= (0); i--) {
    bads -= (delta[arr[i]] != 0);
    delta[arr[i]]++;
    bads += (delta[arr[i]] != 0);
    bads -= (delta[arr[N - 1 - i]] != 0);
    delta[arr[N - 1 - i]]--;
    bads += (delta[arr[N - 1 - i]] != 0);
    bad1[i] = (bads > 0);
    bad1[N - 1 - i] = (bads > 0);
  }
  for (auto i = (0); i < (N); i++) {
    if (arr[i] != arr[N - 1 - i]) bad[i] = true;
  }
  int iter = 0, badlt = 0, badrt = 0;
  for (auto i = (1); i < (N / 2); i++) badrt += bad[i];
  for (auto i = (0); i < (N / 2); i++) {
    while (iter < N / 2) {
      bool ok = true;
      if (iter < i || badlt > 0 || badrt > 0 || bad1[i]) ok = false;
      if (ok) break;
      iter++;
      badrt -= bad[iter];
    }
    badlt += bad[i];
    ans += (N / 2 - iter);
  }
  badlt = 0;
  badrt = 0;
  iter = N - 1;
  for (auto i = ((N - 1) - 1); i >= ((N + 1) / 2); i--) badlt += bad[i];
  for (auto i = ((N)-1); i >= ((N + 1) / 2); i--) {
    while (iter > (N - 1) / 2) {
      bool ok = true;
      if (iter > i || badlt > 0 || badrt > 0 || bad1[i]) ok = false;
      if (ok) break;
      iter--;
      badlt -= bad[iter];
    }
    badrt += bad[i];
    ans += (iter - (N - 1) / 2);
  }
  iter = N / 2;
  bads = 0;
  for (auto i = (0); i < (N); i++) delta[i] = 0;
  for (auto i = (0); i < (iter + 1); i++) delta[arr[i]]++;
  for (auto i = (iter + 1); i < (N); i++) {
    delta[arr[i]]--;
    if (delta[arr[i]] == -1) bads++;
  }
  for (auto i = (0); i < ((N + 1) / 2); i++) {
    while (iter < N - 1 - i) {
      bool ok = true;
      if (bads > 0) ok = false;
      if (ok) break;
      iter++;
      bads -= (delta[arr[iter]] < 0);
      delta[arr[iter]] += 2;
      bads += (delta[arr[iter]] < 0);
    }
    ans += ((N - 1 - i) - iter);
    if (arr[i] != arr[N - 1 - i]) break;
  }
  iter = (N - 1) / 2;
  bads = 0;
  for (auto i = (0); i < (N); i++) delta[i] = 0;
  for (auto i = (iter); i < (N); i++) delta[arr[i]]++;
  for (auto i = (0); i < (iter); i++) {
    delta[arr[i]]--;
    if (delta[arr[i]] == -1) bads++;
  }
  for (auto i = ((N)-1); i >= ((N / 2)); i--) {
    while (iter > N - 1 - i) {
      bool ok = true;
      if (bads > 0) ok = false;
      if (ok) break;
      iter--;
      bads -= (delta[arr[iter]] < 0);
      delta[arr[iter]] += 2;
      bads += (delta[arr[iter]] < 0);
    }
    ans += (iter - (N - 1 - i));
    if (arr[i] != arr[N - 1 - i]) break;
  }
  for (auto i = (0); i < ((N + 1) / 2); i++) {
    ans++;
    if (arr[i] != arr[N - 1 - i]) break;
  }
  cout << ans << '\n';
}
