#include <bits/stdc++.h>
using namespace std;
int n;
long long a[100010];
long long num[100010];
bool check(int ls, int rs) {
  memset(num, 0, sizeof(num));
  for (int i = ls; i <= rs; ++i) {
    num[a[i]]++;
  }
  int ml, mr;
  if (n & 1) {
    if (ls <= n / 2 && rs >= n / 2) {
      if (n / 2 - ls > rs - n / 2) {
        ml = ls;
        mr = n / 2 + n / 2 - rs - 1;
      } else {
        ml = n / 2 + n / 2 - ls + 1;
        mr = rs;
      }
    } else {
      ml = ls;
      mr = rs;
    }
  } else {
    if (ls <= (n - 1) / 2 && rs >= n / 2) {
      if ((n - 1) / 2 - ls > rs - n / 2) {
        ml = ls;
        mr = (n - 1) / 2 - rs + n / 2 - 1;
      } else {
        ml = n / 2 + (n - 1) / 2 - ls + 1;
        mr = rs;
      }
    } else {
      ml = ls;
      mr = rs;
    }
  }
  for (int i = ml; i <= mr; ++i) {
    if (num[a[n - 1 - i]] == 0) {
      return false;
    } else {
      num[a[n - 1 - i]]--;
    }
  }
  int odd = 0;
  for (int i = 1; i <= n; ++i) {
    if (num[i] & 1) {
      odd++;
    }
  }
  if (n & 1) {
    if (ls <= n / 2 && rs >= n / 2) {
      return odd == 1;
    }
  } else {
    if (odd) return false;
  }
  int li, ri;
  if (rs <= n / 2) {
    li = rs + 1;
    ri = n / 2 - 1;
  } else if (ls > n / 2) {
    li = n / 2;
    ri = ls - 1;
  } else {
    return true;
  }
  for (int i = li; i <= ri; ++i) {
    if (a[i] != a[n - 1 - i]) {
      return false;
    }
  }
  return true;
}
long long cal(int lft, int rit, int side) {
  int l = lft, r = rit;
  while (l < r) {
    int mid = side ? (l + r + 1) / 2 : (l + r) / 2;
    int ls = (side ? mid : lft);
    int rs = (side ? rit : mid);
    if (check(ls, rs)) {
      if (side) {
        l = mid;
      } else {
        r = mid;
      }
    } else {
      if (side) {
        r = mid - 1;
      } else {
        l = mid + 1;
      }
    }
  }
  int ls = (side ? r : lft);
  int rs = (side ? rit : r);
  if (!check(ls, rs)) {
    return 0LL;
  }
  return side ? (long long)(r + 1) * (long long)(n - rit)
              : (long long)(lft + 1) * (long long)(n - r);
}
int main() {
  while (cin >> n) {
    for (int i = 0; i < n; ++i) {
      scanf("%I64d", a + i);
    }
    int i;
    for (i = 0; i < n / 2; ++i) {
      if (a[i] != a[n - 1 - i]) {
        break;
      }
    }
    if (i == n / 2) {
      cout << ((long long)n * (long long)(n + 1) / 2LL) << endl;
      continue;
    }
    long long ans = 0LL;
    long long lans = 0LL, rans = 0LL;
    lans = cal(i, n - 1 - i, 0);
    rans = cal(i, n - 1 - i, 1);
    ans = lans + rans;
    if (lans && rans) {
      ans -= (long long)(i + 1) * (long long)(i + 1);
    }
    cout << ans << endl;
  }
  return 0;
}
