#include <bits/stdc++.h>
using namespace std;
long long ans = 0;
int a[110000], s[110000], n, s2[110000], lim1, lim2, lim3;
bool check1() {
  for (int i = 1; i <= n; i++)
    if (a[i] != a[n - i + 1]) return 0;
  return 1;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    s[a[i]]++;
  }
  int t = 0;
  for (int i = 1; i <= n; i++)
    if (s[i] % 2) {
      if (t || n % 2 == 0) {
        printf("0\n");
        return 0;
      }
      t = i;
    }
  if (check1()) {
    cout << (long long)(1 + n) * n / 2 << endl;
    return 0;
  }
  memset(s2, 0, sizeof s2);
  for (int i = 1; i * 2 <= n + 1; i++) {
    s2[a[i]]++;
    lim1++;
    if (s2[a[i]] > s[a[i]] / 2) {
      lim1--;
      break;
    }
  }
  memset(s2, 0, sizeof s2);
  for (int i = n; (n - i + 1) * 2 <= n + 1; i--) {
    s2[a[i]]++;
    lim2++;
    if (s2[a[i]] > s[a[i]] / 2) {
      lim2--;
      break;
    }
  }
  for (int i = 1; i * 2 <= n; i++)
    if (a[i] != a[n - i + 1]) {
      lim3 = i - 1;
      break;
    }
  for (int i = 0; i <= lim3; i++)
    ans +=
        1 + max(min(lim1, n / 2 - 1) - i, 0) + max(min(lim2, n / 2 - 1) - i, 0);
  if (n % 2 == 0) {
    int sum1 = 1, sum2 = 1;
    if (lim1 == n / 2) {
      for (int i = n; i; i--)
        if (a[i] != a[n - i + 1])
          break;
        else
          sum1++;
      for (int i = n / 2 + 1; i <= n; i++)
        if (a[i] != a[n - i + 1])
          break;
        else
          sum2++;
      ans += sum1 * sum2 * 2;
    }
  } else {
    if (lim1 == n / 2) {
      if (a[n / 2 + 1] == t) {
        int sum1 = 1, sum2 = 2;
        for (int i = n; i; i--)
          if (a[i] != a[n - i + 1])
            break;
          else
            sum1++;
        for (int i = n / 2 + 2; i <= n; i++)
          if (a[i] != a[n - i + 1])
            break;
          else
            sum2++;
        ans += sum1 * sum2;
      } else {
        int sum1 = 1;
        for (int i = n; i; i--)
          if (a[i] != a[n - i + 1])
            break;
          else
            sum1++;
        ans += sum1;
      }
    }
    if (lim2 == n / 2) {
      if (a[n / 2 + 1] == t) {
        int sum1 = 1, sum2 = 2;
        for (int i = 1; i <= n; i++)
          if (a[i] != a[n - i + 1])
            break;
          else
            sum1++;
        for (int i = n / 2; i; i--)
          if (a[i] != a[n - i + 1])
            break;
          else
            sum2++;
        ans += sum1 * sum2;
      } else {
        int sum1 = 1;
        for (int i = 1; i <= n; i++)
          if (a[i] != a[n - i + 1])
            break;
          else
            sum1++;
        ans += sum1;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
