#include <bits/stdc++.h>
using namespace std;
int n;
int a[100100];
vector<int> p[100100];
bool vis[100100];
int mn = 1e7;
int mx = -1;
int mxle = 0;
int mxmd = 0;
bool ch(int st, int en) {
  int len = min(st, n - en - 1);
  if (len > mxle) return 0;
  if (st > n / 2) {
    if (st - n / 2 > mxmd) return 0;
  }
  if (en < n / 2 - (n % 2 == 0)) {
    if (n / 2 - (n % 2 == 0) - en > mxmd) return 0;
  }
  return 1;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    p[a[i]].push_back(i);
  }
  int odd = -1;
  for (int val = 0; val <= n; val++) {
    int le = 0, ri = 0, mn1, mx1;
    for (int i = 0; i < p[val].size(); i++) {
      int in = p[val][i];
      vis[in] = 1;
      if (in < n / 2)
        le++;
      else
        ri++;
    }
    if (p[val].size() % 2 != 0) {
      if (odd != -1) {
        cout << 0 << endl;
        return 0;
      }
      odd = val;
      int mid = p[val].size() / 2;
      if (p[val][mid] != n / 2) {
        mn1 = min(p[val][mid], n / 2);
        mx1 = max(p[val][mid], n / 2);
        mn = min(mn1, mn);
        mx = max(mx1, mx);
      }
      if (p[val][mid] < n / 2)
        le--;
      else
        ri--;
    }
    int sz = p[val].size();
    if (le < sz / 2) {
      int sh = sz / 2 - le;
      mx1 = p[val][sz / 2 - 1], mn1;
      for (int i = n / 2 - 1; i >= 0; i--) {
        sh--;
        sh += vis[i];
        if (!sh) {
          mn1 = i;
          break;
        }
      }
      mn = min(mn, mn1);
      mx = max(mx, mx1);
    } else if (ri < sz / 2) {
      int sh = sz / 2 - ri;
      mn1 = p[val][(sz + 1) / 2], mx1;
      for (int i = n / 2; i < n; i++) {
        sh--;
        sh += vis[i];
        if (!sh) {
          mx1 = i;
          break;
        }
      }
      mn = min(mn, mn1);
      mx = max(mx, mx1);
    }
    for (int i = 0; i < p[val].size(); i++) {
      int in = p[val][i];
      vis[in] = 0;
    }
  }
  for (int i = 0; i < n; i++) {
    if (a[i] != a[n - i - 1]) break;
    mxle++;
  }
  if (n % 2 != 0) {
    if (a[n / 2] == odd) {
      mxmd++;
      for (int i = n / 2 - 1, j = n / 2 + 1; i >= 0; i--, j++) {
        if (a[i] != a[j]) break;
        mxmd++;
      }
    }
  } else {
    for (int i = n / 2 - 1, j = n / 2; i >= 0; i--, j++) {
      if (a[i] != a[j]) break;
      mxmd++;
    }
  }
  long long ans = 0;
  if (mx != -1) {
    for (int i = mx; i < n; i++) {
      int l = 0, h = mn, res = -1;
      while (l <= h) {
        int m = (l + h) / 2;
        if (ch(m, i)) {
          res = m;
          l = m + 1;
        } else {
          h = m - 1;
        }
      }
      ans += res + 1;
    }
    cout << ans << endl;
    return 0;
  }
  for (int i = 0; i < n; i++) {
    int l = 0, h = i, res = -1;
    while (l <= h) {
      int m = (l + h) / 2;
      if (ch(m, i)) {
        res = m;
        l = m + 1;
      } else {
        h = m - 1;
      }
    }
    ans += res + 1;
  }
  cout << ans << endl;
  return 0;
}
