#include <bits/stdc++.h>
using namespace std;
int N;
int Array[100005];
int Ap[100005], poz, length, pref, suf;
void Read() {
  int i;
  cin >> N;
  for (i = 1; i <= N; i++) cin >> Array[i], Ap[Array[i]]++;
}
bool checkP(int value) {
  int i, aux = 0;
  for (int i = value + poz; i <= N / 2 + N % 2; i++)
    if (Array[i] != Array[N - i + 1]) return 0;
  for (i = poz; i - poz + 1 <= value; i++) {
    Ap[Array[i]]++;
    if (i > N / 2 + N % 2) ++aux;
  }
  int start = i, aux2 = 0;
  for (; i - poz + 1 <= length; i++) {
    if (N % 2 == 1 && i == N / 2 + 1) continue;
    if (i <= N / 2 + N % 2) Ap[Array[i]]++;
    if (i > N / 2 + N % 2) Ap[Array[i]]--;
  }
  int number = 0;
  for (int i = 1; i <= N; i++) {
    if (Ap[i] < 0) return 0;
    number += Ap[i] % 2;
    if (Ap[i] != 0) aux2 += Ap[i] / 2;
  }
  return number <= 1 && aux2 <= aux;
}
bool checkS(int value) {
  int i, aux = 0;
  for (int i = poz - value; i > N / 2 + N % 2; i--)
    if (Array[i] != Array[N - i + 1]) return 0;
  for (i = poz; poz - i + 1 <= value; i--) {
    Ap[Array[i]]++;
    if (i <= N / 2) aux++;
  }
  int start = i;
  for (; poz - i + 1 <= length; i--) {
    if (N % 2 == 1 && i == N / 2 + 1) continue;
    if (i > N / 2 + N % 2) Ap[Array[i]]++;
    if (i <= N / 2 + N % 2) Ap[Array[i]]--;
  }
  int number = 0, aux2 = 0;
  for (int i = 1; i <= N; i++) {
    if (Ap[i] < 0) return 0;
    number += Ap[i] % 2;
    if (Ap[i] != 0) aux2 += Ap[i] / 2;
  }
  return number <= 1 && aux2 <= aux;
}
int binSearchsuf() {
  int left = 1, right = length, mid, sol;
  while (left <= right) {
    memset(Ap, 0, sizeof(Ap));
    mid = (left + right) / 2;
    if (checkS(mid) == 1) {
      sol = mid;
      right = mid - 1;
    } else
      left = mid + 1;
  }
  return sol;
}
int binSearchpref() {
  int left = 1, right = length, mid, sol;
  while (left <= right) {
    memset(Ap, 0, sizeof(Ap));
    mid = (left + right) / 2;
    if (checkP(mid) == 1) {
      sol = mid;
      right = mid - 1;
    } else
      left = mid + 1;
  }
  return sol;
}
void Solve() {
  int i = 1, ok = 0;
  long long x = N;
  while (i <= N / 2 + N % 2) {
    if (Array[i] != Array[N - i + 1]) {
      ok = 1;
      break;
    }
    ++i;
  }
  poz = i;
  length = N - 2 * i + 2;
  pref = 0;
  suf = 0;
  if (ok == 0) {
    cout << x * (x + 1) / 2 << "\n";
    return;
  }
  int number = 0;
  for (int i = 1; i <= N; i++) number += Ap[i] % 2;
  if (number > 1) {
    cout << 0 << "\n";
    return;
  }
  pref = binSearchpref();
  poz = N - poz + 1;
  suf = binSearchsuf();
  long long aux = (N - length) / 2, res = 0;
  res += aux * (N - pref + 1 - 2 * aux);
  res += aux * (N - suf + 1 - 2 * aux);
  res += aux * aux;
  res += length - pref + 1;
  res += length - suf;
  cout << res << "\n";
}
int main() {
  Read();
  Solve();
  return 0;
}
