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 inf = 1000000009;
struct SufArr {
  static const int max_size = 100009;
  int N;
  char* S;
  int ind[max_size];
  int LCP[max_size];
  int root;
  void Init(int n, char* s) { N = n, S = s; };
  struct tree {
    int L, R;
    int pl, pr;
    int ind;
  } tree[2 * max_size];
  int treeSize;
  int BuildTree(int L, int R) {
    int cur = treeSize++;
    tree[cur].L = L;
    tree[cur].R = R;
    tree[cur].ind = L;
    if (L < R) {
      tree[cur].pl = BuildTree(L, (L + R) / 2);
      tree[cur].pr = BuildTree((L + R) / 2 + 1, R);
    }
    return cur;
  }
  int GetInd(int L, int R, int cur = 0) {
    if (L <= tree[cur].L && R >= tree[cur].R) return tree[cur].ind;
    int ret = -1;
    if (L <= tree[tree[cur].pl].R && tree[tree[cur].pl].L <= R) {
      int tmp = GetInd(L, R, tree[cur].pl);
      if (ret == -1 || LCP[tmp] < LCP[ret]) ret = tmp;
    }
    if (L <= tree[tree[cur].pr].R && tree[tree[cur].pr].L <= R) {
      int tmp = GetInd(L, R, tree[cur].pr);
      if (ret == -1 || LCP[tmp] < LCP[ret]) ret = tmp;
    }
    return ret;
  }
  void Update(int i, int cur) {
    if (tree[cur].L == tree[cur].R) return;
    if (i <= tree[tree[cur].pl].R)
      Update(i, tree[cur].pl);
    else
      Update(i, tree[cur].pr);
    if (LCP[tree[tree[cur].pl].ind] < LCP[tree[tree[cur].pr].ind])
      tree[cur].ind = tree[tree[cur].pl].ind;
    else
      tree[cur].ind = tree[tree[cur].pr].ind;
  }
  int newInd[max_size];
  int posInInd[max_size];
  int bucket[max_size];
  int next[max_size];
  bool update[max_size];
  void Build() {
    root = BuildTree(0, N - 1);
    int cnt[256];
    memset(cnt, 0, sizeof(int) * 256);
    for (int i = 0; i < N; i++) cnt[S[i]]++;
    for (int i = 1; i < 256; i++) cnt[i] += cnt[i - 1];
    for (int i = 0; i < N; i++) ind[--cnt[S[i]]] = i;
    for (int i = 0; i < N; i++) LCP[i] = inf;
    for (int i = 1; i < N; i++) {
      if (S[ind[i]] != S[ind[i - 1]]) {
        bucket[i] = i;
        LCP[i] = 0;
        Update(i, root);
      } else {
        bucket[i] = bucket[i - 1];
      }
    }
    memcpy(newInd, ind, sizeof(int) * N);
    for (int step = 1; step < N; step *= 2) {
      for (int i = 0; i < N; i++) {
        posInInd[ind[i]] = i;
        next[i] = bucket[i];
      }
      for (int i = 0; i < N; i++) {
        if (ind[i] >= step) {
          newInd[next[bucket[posInInd[ind[i] - step]]]++] = ind[i] - step;
        }
      }
      for (int i = 1; i < N; i++) {
        if (LCP[i] == inf && bucket[posInInd[newInd[i] + step]] !=
                                 bucket[posInInd[newInd[i - 1] + step]]) {
          int L = posInInd[newInd[i] + step];
          int R = posInInd[newInd[i - 1] + step];
          if (L > R) swap(L, R);
          LCP[i] = step + LCP[GetInd(L + 1, R, root)];
          update[i] = true;
        }
      }
      memcpy(ind, newInd, sizeof(int) * N);
      for (int i = 1; i < N; i++) {
        if (update[i]) {
          Update(i, root);
          update[i] = false;
        }
        if (LCP[i] == inf)
          bucket[i] = bucket[i - 1];
        else
          bucket[i] = i;
      }
    }
  }
};
char S[100009];
int N;
SufArr sufArr;
long long ans = 0;
void Solve(int L, int R, int k) {
  if (L == R) {
    ans += (N - sufArr.ind[L] - k - 1);
    return;
  }
  int i = sufArr.GetInd(L + 1, R);
  ans += 1LL * (sufArr.LCP[i] - k) * (R - L + 1) * (R - L + 2) / 2;
  Solve(L, i - 1, sufArr.LCP[i]);
  Solve(i, R, sufArr.LCP[i]);
}
int main() {
  cin >> S;
  N = strlen(S);
  S[N++] = 'a' - 1;
  sufArr.Init(N, S);
  sufArr.Build();
  Solve(1, N - 1, 0);
  cout << ans;
}