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 long double eqs = 1e-6;
const long long max_ = 1e5 + 7;
const int mod = 100000;
const int inf = 1e9 + 7;
const long long INF = 1e18;
inline int read() {
  int ret = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -f;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') ret = ret * 10 + ch - '0', ch = getchar();
  return ret * f;
}
inline void write(int x) {
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
int len, siz;
struct {
  int next[27], Len, Fail;
  long long cnt;
} sam[max_ << 1];
char S[max_];
inline void getsam() {
  len = strlen(S + 1);
  sam[0].Fail = -1;
  int fa = 0;
  for (int i = 1; i <= len; i++) {
    int cur = ++siz;
    sam[cur].cnt = 1;
    sam[cur].Len = sam[fa].Len + 1;
    int now = fa;
    while (now != -1 && !sam[now].next[S[i] - 'a']) {
      sam[now].next[S[i] - 'a'] = cur;
      now = sam[now].Fail;
    }
    if (now == -1) {
      sam[cur].Fail = 0;
    } else {
      int to = sam[now].next[S[i] - 'a'];
      if (sam[now].Len + 1 == sam[to].Len) {
        sam[cur].Fail = to;
      } else {
        int clone = ++siz;
        sam[clone] = sam[to];
        sam[clone].cnt = 0;
        sam[clone].Len = sam[now].Len + 1;
        while (now != -1 && sam[now].next[S[i] - 'a'] == to) {
          sam[now].next[S[i] - 'a'] = clone;
          now = sam[now].Fail;
        }
        sam[to].Fail = sam[cur].Fail = clone;
      }
    }
    fa = cur;
  }
}
int sor[max_], id[max_ << 1];
long long ans = 0;
inline long long cal(long long a, long long b) {
  if (a % 2)
    return b / 2 * a;
  else
    return a / 2 * b;
}
inline void getcishu() {
  for (int i = 1; i <= siz; i++) sor[sam[i].Len]++;
  for (int i = 1; i <= len; i++) sor[i] += sor[i - 1];
  for (int i = siz; i >= 1; i--) id[sor[sam[i].Len]--] = i;
  for (int i = siz; i >= 1; i--) {
    sam[sam[id[i]].Fail].cnt += sam[id[i]].cnt;
    ans += (sam[id[i]].Len - sam[sam[id[i]].Fail].Len) *
           cal(sam[id[i]].cnt, sam[id[i]].cnt + 1);
  }
}
signed main() {
  cin >> S + 1;
  getsam();
  getcishu();
  cout << ans;
  return 0;
}