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 state {
  int len, link;
  map<char, int> next;
};
state node[2 * 1000000 + 5];
int sz, last;
long long cnt[2 * 1000000 + 5];
long long mark[2 * 1000000 + 5] = {0};
vector<pair<int, int> > vt;
inline void init() {
  sz = last = 0;
  node[0].len = 0;
  node[0].link = -1;
  ++sz;
}
inline void Insert(char c) {
  int cur = sz++;
  node[cur].len = node[last].len + 1;
  int p;
  for (p = last; p != -1 && !node[p].next.count(c); p = node[p].link)
    node[p].next[c] = cur;
  if (p == -1) {
    node[cur].link = 0;
  } else {
    int q = node[p].next[c];
    if (node[p].len + 1 == node[q].len) {
      node[cur].link = q;
    } else {
      int clone = sz++;
      node[clone].len = node[p].len + 1;
      node[clone].next = node[q].next;
      node[clone].link = node[q].link;
      for (; p != -1 && node[p].next[c] == q; p = node[p].link)
        node[p].next[c] = clone;
      node[q].link = node[cur].link = clone;
      cnt[clone] = 0ll;
      vt.push_back(make_pair(node[clone].len, clone));
    }
  }
  cnt[cur] = 1ll;
  vt.push_back(make_pair(node[cur].len, cur));
  last = cur;
  return;
}
char s[1000000 + 5];
long long dp[2 * 1000000 + 5];
inline long long solve(int u) {
  if (dp[u] != -1ll) return dp[u];
  dp[u] = cnt[u];
  for (pair<char, int> x : node[u].next) {
    dp[u] += solve(x.second);
  }
  return dp[u];
}
int main() {
  init();
  scanf("%s", s);
  int n = strlen(s);
  for (int i = 0; i < n; i++) {
    Insert(s[i]);
  }
  sort(vt.rbegin(), vt.rend());
  mark[last] = 1;
  for (pair<int, int> x : vt) {
    cnt[node[x.second].link] += cnt[x.second];
    long long y = cnt[x.second];
    cnt[x.second] = y * (y + 1ll) / 2ll;
  }
  cnt[0] = 0ll;
  memset((dp), (-1ll), sizeof((dp)));
  ;
  printf("%lld\n", solve(0));
  ;
  return 0;
}