Problem: In an English class Nick had nothing to do at all, and remembered about wonderful strings called palindromes. We should remind you that a string is called a palindrome if it can be read the same way both from left to right and from right to left. Here are examples of such strings: «eye», «pop», «level», «aba», «deed», «racecar», «rotor», «madam». 

Nick started to look carefully for all palindromes in the text that they were reading in the class. For each occurrence of each palindrome in the text he wrote a pair — the position of the beginning and the position of the ending of this occurrence in the text. Nick called each occurrence of each palindrome he found in the text subpalindrome. When he found all the subpalindromes, he decided to find out how many different pairs among these subpalindromes cross. Two subpalindromes cross if they cover common positions in the text. No palindrome can cross itself.

Let's look at the actions, performed by Nick, by the example of text «babb». At first he wrote out all subpalindromes:

• «b» — 1..1 • «bab» — 1..3 • «a» — 2..2 • «b» — 3..3 • «bb» — 3..4 • «b» — 4..4

Then Nick counted the amount of different pairs among these subpalindromes that cross. These pairs were six:

1. 1..1 cross with 1..3 2. 1..3 cross with 2..2 3. 1..3 cross with 3..3 4. 1..3 cross with 3..4 5. 3..3 cross with 3..4 6. 3..4 cross with 4..4

Since it's very exhausting to perform all the described actions manually, Nick asked you to help him and write a program that can find out the amount of different subpalindrome pairs that cross. Two subpalindrome pairs are regarded as different if one of the pairs contains a subpalindrome that the other does not.

Input

The first input line contains integer n (1 ≤ n ≤ 2·106) — length of the text. The following line contains n lower-case Latin letters (from a to z).

Output

In the only line output the amount of different pairs of two subpalindromes that cross each other. Output the answer modulo 51123987.

Examples

Input

4
babb


Output

6


Input

2
aa


Output

2

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
const int MAXN = 2e6 + 10;
const long long MOD = 51123987;
using namespace std;
char S[MAXN * 2];
int P[MAXN * 2];
char STR_TMP[MAXN * 2];
int s_len;
void read() {
  scanf("%d", &s_len);
  scanf("%s", &STR_TMP);
}
void manacher() {
  s_len = 0;
  S[s_len++] = '#';
  for (int i = 0; STR_TMP[i]; i++) {
    S[s_len++] = STR_TMP[i];
    S[s_len++] = '#';
  }
  S[s_len] = 0;
  P[0] = 0;
  int id = 0, mx = 0;
  for (int i = 1; i < s_len; i++) {
    if (i <= mx)
      P[i] = min(P[2 * id - i], mx - i);
    else
      P[i] = 0;
    for (; i + P[i] < s_len && i - P[i] >= 0 && S[i + P[i]] == S[i - P[i]];
         P[i]++)
      ;
    P[i]--;
    if (i + P[i] > mx) {
      id = i;
      mx = i + P[i];
    }
  }
}
void test() {
  scanf("%s", &STR_TMP);
  manacher();
  for (int i = 0; i < s_len; i++) {
    printf("%d ", P[i]);
  }
}
int get_real_pos(int p) { return p / 2; }
struct chafen_seq {
  long long a[MAXN];
  void init() { memset(a, 0, sizeof(a)); }
  void add(int l, int r, int num) {
    l = get_real_pos(l);
    r = get_real_pos(r);
    a[l] += num;
    a[r + 1] -= num;
    a[l] %= MOD;
    a[r + 1] %= MOD;
  }
  void make_pre_sum() {
    for (int i = 1; i < MAXN; i++) {
      a[i] += a[i - 1];
      a[i] %= MOD;
    }
  }
  long long operator[](int i) { return a[i]; }
} LEFT, RIGHT;
void make_left_and_right() {
  for (int i = 1; i < s_len; i++) {
    if (P[i] != 0) {
      if (S[i] == '#') {
        LEFT.add(i - (P[i] - 1), i - 1, 1);
        RIGHT.add(i + 1, i + (P[i] - 1), 1);
      } else {
        LEFT.add(i - (P[i] - 1), i, 1);
        RIGHT.add(i, i + (P[i] - 1), 1);
      }
    }
  }
  LEFT.make_pre_sum();
  RIGHT.make_pre_sum();
}
long long TMP_INT[MAXN];
long long pow(long long d, long long k) {
  if (k == 0)
    return 1;
  else {
    long long tmp = pow(d, k / 2);
    tmp = tmp * tmp;
    tmp %= MOD;
    if (k % 2) tmp *= d;
    return tmp % MOD;
  }
}
void work() {
  manacher();
  make_left_and_right();
  TMP_INT[0] = RIGHT[0];
  for (int i = 1; i < MAXN; i++) {
    TMP_INT[i] = RIGHT[i] + TMP_INT[i - 1];
    TMP_INT[i] %= MOD;
  }
  long long tot = 0, ans = 0;
  for (int i = 1; i < MAXN; i++) {
    ans += TMP_INT[i - 1] * LEFT[i];
    ans %= MOD;
  }
  for (int i = 0; i < MAXN; i++) {
    tot += LEFT[i];
    tot %= MOD;
  }
  tot = (tot * (tot - 1)) % MOD;
  tot = (tot * 25561994) % MOD;
  ans = (tot + MOD - ans) % MOD;
  cout << ans << endl;
}
int main() {
  read();
  work();
  return 0;
}