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 = (int)1e5 + 1;
char s[maxn];
const int ci = 26;
struct vertex {
  vertex *go[ci];
  vertex *suf;
  bool term;
  int len;
  int d[2];
  vertex(int _len = 0) : suf(0), term(0), len(_len) {
    for (int i = 0; i < ci; i++) go[i] = 0;
  }
};
vertex vs[2 * maxn];
vertex *last;
int m;
void addch(int ch) {
  vs[m++] = vertex();
  vertex *newlast = &vs[m - 1];
  newlast->len = last->len + 1;
  for (; last && !last->go[ch]; last = last->suf) last->go[ch] = newlast;
  if (!last)
    newlast->suf = &vs[0];
  else {
    vertex *next = last->go[ch];
    if (last->len + 1 == next->len)
      newlast->suf = next;
    else {
      vs[m++] = *next;
      vertex *clone = &vs[m - 1];
      clone->len = last->len + 1;
      next->suf = clone;
      newlast->suf = clone;
      for (; last && last->go[ch] == next; last = last->suf)
        last->go[ch] = clone;
    }
  }
  last = newlast;
}
int checked[maxn];
void dfscheck(vertex *v, string s, string now) {
  if (v->term) {
    assert(now == string(s, (int)s.length() - (int)now.length()));
    checked[(int)now.length()]++;
  }
  for (int i = 0; i < ci; i++)
    if (v->go[i]) dfscheck(v->go[i], s, now + (char)('a' + i));
}
vertex *fivs[2 * maxn];
const int maxl = 2 * maxn;
int cnt[maxl];
int head[maxl];
int main() {
  while (scanf("%s", s) >= 1) {
    m = 0;
    vs[m++] = vertex();
    last = &vs[0];
    int n = strlen(s);
    for (int i = 0; i < n; i++) {
      addch(s[i] - 'a');
    }
    for (vertex *now = last; now; now = now->suf) now->term = 1;
    memset(cnt, 0, sizeof(cnt));
    for (int i = 0; i < m; i++) cnt[vs[i].len]++;
    head[0] = 0;
    for (int i = 1; i < m; i++) head[i] = head[i - 1] + cnt[i - 1];
    for (int i = 0; i < m; i++) fivs[head[vs[i].len]++] = &vs[i];
    reverse(fivs, fivs + m);
    for (int i = 0; i < m; i++) {
      vertex *v = fivs[i];
      v->d[0] = (int)v->term;
      for (int j = 0; j < ci; j++)
        if (v->go[j]) v->d[0] += v->go[j]->d[0];
      v->d[1] = 0;
    }
    fivs[m - 1]->d[1] = 1;
    for (int i = m - 1; i >= 0; i--) {
      vertex *v = fivs[i];
      for (int j = 0; j < ci; j++)
        if (v->go[j]) v->go[j]->d[1] += v->d[1];
    }
    long long ans = 0;
    for (int i = 0; i < m - 1; i++) {
      int f = fivs[i]->d[0], s = fivs[i]->d[1];
      ans += (long long)s * (long long)f * (f + 1) / 2;
    }
    printf(
        "%lld"
        "\n",
        ans);
  }
  return 0;
}