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;
ifstream fin("in.in");
ofstream fout("out.out");
const int N = 1e5 + 10, L = 20;
const long long E = 1e6;
int n, suff[N];
long long ans, cur, ind[L][N];
string s;
map<int, int, greater<int> > m;
map<int, int, greater<int> >::iterator it;
inline int LCP(int i, int j) {
  int lcp = 0;
  for (int l = L - 1; l >= 0; l--)
    if (ind[l][i] == ind[l][j]) {
      lcp += 1 << l;
      i += 1 << l;
      j += 1 << l;
    }
  return lcp;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> s;
  n = s.length();
  vector<int> v;
  for (int i = 0; i < n; i++) v.push_back(s[i] - 'a' + 1);
  sort(v.begin(), v.end());
  v.resize(unique(v.begin(), v.end()) - v.begin());
  for (int i = 0; i < n; i++)
    ind[0][i] =
        (lower_bound(v.begin(), v.end(), s[i] - 'a' + 1) - v.begin()) + 1;
  for (int l = 1; l < L; l++) {
    vector<long long> v;
    for (int i = 0; i < n; i++) {
      ind[l][i] = E * ind[l - 1][i];
      int next = i + (1 << l - 1);
      if (next < n) ind[l][i] += ind[l - 1][next];
      v.push_back(ind[l][i]);
    }
    sort(v.begin(), v.end());
    v.resize(unique(v.begin(), v.end()) - v.begin());
    for (int i = 0; i < n; i++)
      ind[l][i] = (lower_bound(v.begin(), v.end(), ind[l][i]) - v.begin()) + 1;
  }
  for (int i = 0; i < n; i++) suff[ind[L - 1][i] - 1] = i;
  ans = cur = n - suff[0];
  m[n - suff[0]]++;
  for (int i = 1; i < n; i++) {
    cur += n - suff[i];
    int l = LCP(suff[i], suff[i - 1]), cnt = 0;
    while (!m.empty() && m.begin()->first > l) {
      it = m.begin();
      cur -= it->second * (it->first - l);
      cnt += it->second;
      m.erase(it);
    }
    m[l] += cnt;
    m[n - suff[i]]++;
    ans += cur;
  }
  cout << ans << endl;
  return 0;
}