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;
class SuffixAutomaton {
 private:
  struct Node {
    int len, link;
    bool clone = false;
    map<char, int> next;
  };
  int last = 0;
  vector<Node> dag;

 public:
  SuffixAutomaton(const string& str = "") {
    dag.reserve(str.size() * 2);
    dag.emplace_back();
    dag[0].len = 0;
    dag[0].link = -1;
    last = 0;
    for (char chr : str) extend(chr);
  }
  void extend(char chr) {
    int now = dag.size();
    dag.emplace_back();
    dag[now].len = dag[last].len + 1;
    int p = last;
    while (p != -1 && !dag[p].next.count(chr)) {
      dag[p].next[chr] = now;
      p = dag[p].link;
    }
    if (p == -1)
      dag[now].link = 0;
    else {
      int q = dag[p].next[chr];
      if (dag[q].len == dag[p].len + 1)
        dag[now].link = q;
      else {
        int clone = dag.size();
        dag.emplace_back();
        dag[clone].clone = true;
        dag[clone].len = dag[p].len + 1;
        dag[clone].next = dag[q].next;
        dag[clone].link = dag[q].link;
        while (p != -1 && dag[p].next[chr] == q) {
          dag[p].next[chr] = clone;
          p = dag[p].link;
        }
        dag[q].link = dag[now].link = clone;
      }
    }
    last = now;
  }
  int64_t solve() {
    vector<int64_t> dp(dag.size());
    vector<int> nodes(dag.size());
    for (int i = 0; i < (int)dag.size(); i++) nodes[i] = i;
    sort(nodes.begin(), nodes.end(),
         [&](int x, int y) { return dag[x].len > dag[y].len; });
    for (int node : nodes)
      if (!dag[node].clone) dp[node] = 1;
    for (int node : nodes)
      if (dag[node].link != -1) dp[dag[node].link] += dp[node];
    vector<int> topo;
    vector<bool> vis(dag.size());
    function<void(int)> dfs = [&](int node) {
      vis[node] = true;
      for (auto nghb : dag[node].next)
        if (!vis[nghb.second]) dfs(nghb.second);
      topo.push_back(node);
    };
    dfs(0);
    reverse(topo.begin(), topo.end());
    vector<int64_t> nr(dag.size());
    nr[0] = 1;
    for (int node : topo)
      for (auto nghb : dag[node].next) nr[nghb.second] += nr[node];
    int64_t ans = 0;
    for (int i = 1; i < (int)dag.size(); i++)
      ans += nr[i] * dp[i] * (dp[i] + 1) / 2;
    return ans;
  }
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  string str;
  cin >> str;
  SuffixAutomaton sa(str);
  cout << sa.solve() << '\n';
  return 0;
}