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 = 100 * 1000 + 10;
const int LGN = 20;
string s;
int n;
int r[LGN][MAXN];
int lcp(int a, int b) {
  int ans = 0;
  for (int i = LGN - 1; i >= 0; i--) {
    if (r[i][a] == r[i][b]) {
      ans += 1 << i;
      a += 1 << i;
      b += 1 << i;
    }
  }
  return ans;
}
int suf[MAXN];
void calSuf() {
  for (int i = 0; i < n; i++) r[0][i] = s[i];
  vector<pair<pair<int, int>, int> > v(n);
  for (int j = 1; j < LGN; j++) {
    for (int i = 0; i < n; i++)
      v[i] = make_pair(make_pair(r[j - 1][i], (i + (1 << (j - 1)) < n)
                                                  ? r[j - 1][i + (1 << (j - 1))]
                                                  : -1),
                       i);
    sort((v).begin(), (v).end());
    for (int i = 0; i < n; i++)
      r[j][v[i].second] =
          (i && v[i - 1].first == v[i].first) ? r[j][v[i - 1].second] : i + 1;
  }
  for (int i = 0; i < n; i++) suf[i] = v[i].second;
}
int par[MAXN];
int sz[MAXN];
int gPar(int u) {
  if (par[u] == u) return u;
  return par[u] = gPar(par[u]);
}
inline long long int cmb(long long int x) { return (x * (x + 1)) / 2; }
vector<pair<int, int> > eve[MAXN];
int main() {
  ios::sync_with_stdio(false);
  cin >> s;
  n = s.size();
  calSuf();
  long long int ans = 0;
  for (int i = 0; i < n - 1; i++)
    eve[lcp(suf[i], suf[i + 1])].push_back(make_pair(i, i + 1));
  long long int sum = 0;
  for (int i = n; i; i--) {
    sum++;
    sz[n - i] = 1;
    par[n - i] = n - i;
    for (int j = 0; j < eve[i].size(); j++) {
      int u = suf[eve[i][j].first];
      int v = suf[eve[i][j].second];
      u = gPar(u);
      v = gPar(v);
      sum -= cmb(sz[u]);
      sum -= cmb(sz[v]);
      par[u] = v;
      sz[v] += sz[u];
      sum += cmb(sz[v]);
    }
    ans += sum;
  }
  cout << ans << endl;
  return 0;
}