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;
struct SA {
  int p[100111];
  int cnt[100111];
  int c[18][100111];
  int logs[100111];
  const int alphabet = 256;
  int n;
  void init() {
    memset(p, 0, sizeof(p));
    memset(cnt, 0, sizeof(cnt));
    memset(c, 0, sizeof(c));
  }
  void sort_cyclic_shifts(string &s) {
    int h, i;
    n = (int)s.size();
    for (i = 2; i < 100111; ++i) logs[i] = logs[i / 2] + 1;
    for (i = 0; i < n; i++) cnt[(int)s[i]]++;
    for (i = 1; i < alphabet; i++) cnt[i] += cnt[i - 1];
    for (i = 0; i < n; i++) p[--cnt[(int)s[i]]] = i;
    c[0][p[0]] = 0;
    int classes = 1;
    for (i = 1; i < n; i++) {
      if (s[p[i]] != s[p[i - 1]]) classes++;
      c[0][p[i]] = classes - 1;
    }
    vector<int> pn(n), cn(n);
    for (h = 0; (1 << h) < n; ++h) {
      for (i = 0; i < n; i++) {
        pn[i] = p[i] - (1 << h);
        if (pn[i] < 0) pn[i] += n;
      }
      fill(cnt, cnt + classes, 0);
      for (i = 0; i < n; i++) cnt[c[h][pn[i]]]++;
      for (i = 1; i < classes; i++) cnt[i] += cnt[i - 1];
      for (i = n - 1; i >= 0; i--) p[--cnt[c[h][pn[i]]]] = pn[i];
      cn[p[0]] = 0;
      classes = 1;
      for (i = 1; i < n; i++) {
        pair<int, int> cur = {c[h][p[i]], c[h][(p[i] + (1 << h)) % n]};
        pair<int, int> prev = {c[h][p[i - 1]], c[h][(p[i - 1] + (1 << h)) % n]};
        if (cur != prev) ++classes;
        cn[p[i]] = classes - 1;
      }
      for (i = 0; i < n; ++i) {
        c[h + 1][i] = cn[i];
      }
    }
  }
  int lcp(int i, int j) {
    int ans = 0, k;
    for (k = logs[n]; k >= 0; k--) {
      if (c[k][i] == c[k][j]) {
        ans += 1 << k;
        i += 1 << k;
        j += 1 << k;
      }
    }
    return ans;
  }
};
SA sa;
string s;
char st[100111];
vector<int> height;
vector<pair<pair<int, int>, long long>> vc;
int main() {
  int T = 1, i;
  long long ans = 0, curr = 0;
  while (T-- > 0) {
    ans = 0;
    sa.init();
    s.clear();
    height.clear();
    vc.clear();
    scanf("%s", st);
    s = string(st);
    s += '$';
    sa.sort_cyclic_shifts(s);
    for (i = 1; i < sa.n - 1; ++i) {
      height.push_back(sa.lcp(sa.p[i], sa.p[i + 1]));
    }
    for (i = 0; i < (int)height.size(); ++i) {
      while (!vc.empty() && height[i] <= vc.back().first.first) {
        vc.pop_back();
      }
      if (vc.empty()) {
        curr = 1ll * (i + 1) * height[i];
      } else {
        curr =
            1ll * (i - vc.back().first.second) * height[i] + vc.back().second;
      }
      ans += curr;
      vc.push_back(make_pair(make_pair(height[i], i), curr));
    }
    int N = strlen(st);
    ans = ans + 1ll * N * (N + 1) / 2;
    printf("%I64d\n", ans);
  }
  return 0;
}