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;
inline int in() {
  int x;
  scanf("%d", &x);
  return x;
}
const int N = 1e5 + 10;
const int L = 30;
const int MOD = 1e9 + 7;
const long double eps = 1e-12;
string s;
long long n, suf[N], sz[N], par[N];
long long WTF[L][N];
pair<pair<int, int>, int> tmp[N];
vector<pair<int, int> > add;
long long ans;
int lcp(int x, int y, int res = 0) {
  if (x == y) return n - x;
  for (int i = L - 1; i >= 0 && x < n && y < n; i--)
    if (WTF[i][x] == WTF[i][y]) x += (1 << i), y += (1 << i), res |= (1 << i);
  return res;
}
int find(int v) { return (par[v] == v ? v : par[v] = find(par[v])); }
void merge(int x, int y, int len) {
  x = find(x), y = find(y);
  ans += (sz[x] * sz[y]) * len;
  sz[x] += sz[y];
  par[y] = x;
}
int main() {
  for (int i = 0; i < N; i++) par[i] = i, sz[i] = 1;
  cin >> s;
  n = s.length();
  for (int i = 0; i < n; i++) WTF[0][i] = s[i];
  for (int i = 1; i < L; i++) {
    for (int j = 0; j < n; j++)
      if (j + (1 << (i - 1)) < n)
        tmp[j] = {{WTF[i - 1][j], WTF[i - 1][j + (1 << (i - 1))]}, j};
      else
        tmp[j] = {{WTF[i - 1][j], -1}, j};
    sort(tmp, tmp + n);
    for (int j = 1; j < n; j++)
      if (tmp[j].first == tmp[j - 1].first)
        WTF[i][tmp[j].second] = WTF[i][tmp[j - 1].second];
      else
        WTF[i][tmp[j].second] = j;
  }
  for (int i = 0; i < n; i++) suf[i] = tmp[i].second;
  for (int i = 0; i + 1 < n; i++) {
    int x = lcp(suf[i], suf[i + 1]);
    add.push_back({x, i});
  }
  sort(add.begin(), add.end());
  reverse(add.begin(), add.end());
  for (int i = 0; i < add.size(); i++) {
    int y = add[i].second;
    merge(y, y + 1, add[i].first);
  }
  cout << ans + n * (n + 1) / 2;
  return 0;
}