Problem: You are given a string s. Each pair of numbers l and r that fulfill the condition 1 ≤ l ≤ r ≤ |s|, correspond to a substring of the string s, starting in the position l and ending in the position r (inclusive).

Let's define the function of two strings F(x, y) like this. We'll find a list of such pairs of numbers for which the corresponding substrings of string x are equal to string y. Let's sort this list of pairs according to the pair's first number's increasing. The value of function F(x, y) equals the number of non-empty continuous sequences in the list.

For example: F(babbabbababbab, babb) = 6. The list of pairs is as follows:

(1, 4), (4, 7), (9, 12)

Its continuous sequences are: 

  * (1, 4)
  * (4, 7)
  * (9, 12)
  * (1, 4), (4, 7)
  * (4, 7), (9, 12)
  * (1, 4), (4, 7), (9, 12)



Your task is to calculate for the given string s the sum F(s, x) for all x, that x belongs to the set of all substrings of a string s.

Input

The only line contains the given string s, consisting only of small Latin letters (1 ≤ |s| ≤ 105).

Output

Print the single number — the sought sum.

Please do not use the %lld specificator to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specificator.

Examples

Input

aaaa


Output

20


Input

abcdef


Output

21


Input

abacabadabacaba


Output

188

Note

In the first sample the function values at x equal to "a", "aa", "aaa" and "aaaa" equal 10, 6, 3 and 1 correspondingly.

In the second sample for any satisfying x the function value is 1.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int maxn = 300864;
struct sam {
  sam *son[26], *pre;
  int len;
  long long cnt;
  void init() {
    memset(son, 0, sizeof(son));
    pre = 0;
    len = 0;
    cnt = 0;
  }
} que[maxn], *root, *tail, *b[maxn];
int tot;
void initt() {
  tot = 0;
  tail = root = &que[tot++];
  root->init();
}
void add(int c, int len) {
  sam *p = tail, *np = &que[tot++];
  np->init();
  np->len = len;
  tail = np;
  for (; p && p->son[c] == NULL; p = p->pre) p->son[c] = np;
  if (p == NULL)
    np->pre = root;
  else {
    sam *q = p->son[c];
    if (p->len + 1 == q->len)
      np->pre = q;
    else {
      sam *nq = &que[tot++];
      *nq = *q;
      nq->len = p->len + 1;
      np->pre = q->pre = nq;
      for (; p && p->son[c] == q; p = p->pre) p->son[c] = nq;
    }
  }
}
char str[maxn];
int cup[maxn];
int main() {
  while (~scanf("%s", str)) {
    initt();
    for (int i = 0; str[i]; i++) add(str[i] - 'a', i + 1);
    sam *p = root;
    memset(cup, 0, sizeof(cup));
    int m = strlen(str);
    for (int i = 0; i < tot; i++) cup[que[i].len]++;
    for (int i = 1; i <= m; i++) cup[i] += cup[i - 1];
    for (int i = 0; i < tot; i++) b[--cup[que[i].len]] = &que[i];
    for (int i = 0; str[i]; i++) {
      int c = str[i] - 'a';
      p = p->son[c];
      p->cnt++;
    }
    for (int i = tot - 1; i > 0; i--) {
      p = b[i];
      p->pre->cnt += p->cnt;
    }
    long long ans = 0;
    for (int i = tot - 1; i > 0; i--) {
      p = b[i];
      long long tmp = (((p->len - p->pre->len) * (p->cnt + 1) * p->cnt) / 2);
      ans += tmp;
    }
    cout << ans << endl;
  }
  return 0;
}