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;
char str[100010];
long long n, l[100010], r[100010], ofs, stk[100010], sa[100010], rk[100010],
    tmp[100010], hei[100010];
vector<long long> ll[100010], rr[100010];
void build_sa(char *str, long long sa[]);
void build_hei(char *str, long long sa[], long long hei[]);
int main() {
  scanf("%s", str);
  n = strlen(str);
  build_sa(str, sa);
  build_hei(str, sa, hei);
  long long i, k;
  for (k = 0, i = 1; i <= n - 1; i++) {
    while (k && hei[stk[k]] >= hei[i]) k--;
    l[i] = (k ? stk[k] + 1 : 1);
    stk[++k] = i;
  }
  for (k = 0, i = n - 1; i >= 1; i--) {
    while (k && hei[stk[k]] >= hei[i]) k--;
    r[i] = (k ? stk[k] - 1 : n - 1);
    stk[++k] = i;
  }
  for (i = 1; i <= n - 1; i++)
    if (hei[i] && (ll[hei[i]].empty() || l[i] != ll[hei[i]].back())) {
      ll[hei[i]].push_back(l[i]);
      rr[hei[i]].push_back(r[i]);
    }
  long long ans = 0, p, q;
  for (hei[0] = hei[n] = 0, i = 1; i <= n - 1; i++)
    while (!ll[i].empty()) {
      p = ll[i].back();
      q = rr[i].back();
      ans += (q - p + 2) * (q - p + 3) / 2 * (i - max(hei[p - 1], hei[q + 1]));
      ll[i].pop_back();
      rr[i].pop_back();
    }
  for (i = 1; i <= n; i++) ans += n - sa[i] + 1 - max(hei[i], hei[i - 1]);
  printf("%I64d\n", ans);
  return 0;
}
bool cmp(long long i, long long j) {
  if (rk[i] != rk[j]) return rk[i] < rk[j];
  long long ri = (i + ofs <= n ? rk[i + ofs] : -1),
            rj = (j + ofs <= n ? rk[j + ofs] : -1);
  return ri < rj;
}
void build_sa(char *str, long long sa[]) {
  long long i;
  for (i = 1; i <= n; i++) {
    sa[i] = i;
    rk[i] = str[i - 1];
  }
  for (ofs = 1; ofs <= n; ofs *= 2) {
    sort(sa + 1, sa + n + 1, cmp);
    for (tmp[sa[1]] = 1, i = 2; i <= n; i++)
      tmp[sa[i]] = tmp[sa[i - 1]] + (cmp(sa[i - 1], sa[i]) ? 1 : 0);
    for (i = 1; i <= n; i++) rk[i] = tmp[i];
  }
}
void build_hei(char *str, long long sa[], long long hei[]) {
  long long h = 0, i, j;
  for (i = 1; i <= n; i++) {
    if (rk[i] == n) continue;
    j = sa[rk[i] + 1];
    if (h) h--;
    for (; j + h <= n && i + h <= n; h++)
      if (str[j + h - 1] != str[i + h - 1]) break;
    hei[rk[i]] = h;
  }
}