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 MAXLEN = (600005);
const int Alpha = 28;
long long MOD = 1e9 + 7;
struct state {
  int len, link;
  int next[Alpha];
  state() {
    len = link = 0;
    memset(next, -1, sizeof(next));
  }
};
state st[MAXLEN * 2];
int terminal[MAXLEN * 2];
int dp[MAXLEN * 2][11];
int n;
int L[1000];
int R[1000];
bool vis[1000000];
class SuffixAutomata {
 public:
  int sz = 1, last = 0;
  void Clear() {
    for (int j = 0; j < sz; j++) {
      st[j] = state(), terminal[j] = 0;
    }
    st[0].len = 0;
    st[0].link = -1;
    sz = 1;
    last = 0;
  }
  void extend(char ccc) {
    int c = ccc - 'a';
    int cur = sz++;
    st[cur].len = st[last].len + 1;
    int p = last;
    while (p != -1 && st[p].next[c] == -1) {
      st[p].next[c] = cur;
      p = st[p].link;
    }
    if (p == -1) {
      st[cur].link = 0;
    } else {
      int q = st[p].next[c];
      if (st[p].len + 1 == st[q].len) {
        st[cur].link = q;
      } else {
        int clone = sz++;
        st[clone].len = st[p].len + 1;
        for (int j = 0; j < Alpha; j++) st[clone].next[j] = st[q].next[j];
        st[clone].link = st[q].link;
        while (p != -1 && st[p].next[c] == q) {
          st[p].next[c] = clone;
          p = st[p].link;
        }
        st[q].link = st[cur].link = clone;
      }
    }
    last = cur;
  }
  void getTerminal() {
    int p = last;
    while (p > 0) terminal[p] = 1, p = st[p].link;
  }
  void build(string s) {
    for (auto x : s) extend(x);
    getTerminal();
  }
  int DP(int i, int j) {
    if (j < 0) return 0;
    if (dp[i][j] != -1) return dp[i][j];
    int ret = (terminal[i] && j == 0);
    for (int x = 0; x < Alpha; x++)
      if (st[i].next[x] != -1) ret += DP(st[i].next[x], j - (x == ('|' - 'a')));
    return dp[i][j] = ret;
  }
  void solve(string s) {
    long long ret = 0;
    for (int i = 1; i < sz; i++) {
      long long cur = DP(i, 0);
      cur = cur * (cur + 1) / 2;
      cur = cur * (st[i].len - st[st[i].link].len);
      ret += cur;
    }
    cout << ret << endl;
  }
} SA;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  memset(dp, -1, sizeof(dp));
  string s;
  cin >> s;
  SA.Clear();
  SA.build(s);
  SA.solve(s);
}