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;
void debug() { cout << endl; }
template <typename T, typename... Args>
void debug(T a, Args... args) {
  cout << a << " ";
  debug(args...);
}
struct suffixAutomaton {
  struct node {
    int len, link;
    bool end;
    map<char, int> next;
    bool vis = false;
    long long in, subs;
  };
  vector<node> sa;
  int last;
  long long substrs = 0;
  suffixAutomaton() {}
  suffixAutomaton(string &s) {
    sa.reserve(s.size() * 2);
    last = add_node();
    sa[0].link = -1;
    sa[0].in = 1;
    for (char &c : s) add_char(c);
    for (int p = last; p; p = sa[p].link) sa[p].end = 1;
  }
  int add_node() {
    sa.push_back({});
    return sa.size() - 1;
  }
  void add_char(char c) {
    int u = add_node(), p = last;
    sa[u].len = sa[last].len + 1;
    while (p != -1 && !sa[p].next.count(c)) {
      sa[p].next[c] = u;
      sa[u].in += sa[p].in;
      substrs += sa[p].in;
      p = sa[p].link;
    }
    if (p != -1) {
      int q = sa[p].next[c];
      if (sa[p].len + 1 != sa[q].len) {
        int clone = add_node();
        sa[clone] = sa[q];
        sa[clone].len = sa[p].len + 1;
        sa[clone].in = 0;
        sa[q].link = sa[u].link = clone;
        while (p != -1 && sa[p].next[c] == q) {
          sa[p].next[c] = clone;
          sa[q].in -= sa[p].in;
          sa[clone].in += sa[p].in;
          p = sa[p].link;
        }
      } else
        sa[u].link = q;
    }
    last = u;
  }
  node &operator[](int i) { return sa[i]; }
  long long calc(long long cnt) { return (cnt * (cnt + 1)) / 2; }
  long long go() {
    f(0);
    long long r = 0;
    int n = sa.size();
    for (int u = 1; u < n; ++u) {
      int par = sa[u].link;
      r += calc(sa[u].subs) * (sa[u].len - sa[par].len);
    }
    return r;
  }
  long long f(int u) {
    long long &ans = sa[u].subs;
    if (sa[u].vis) return ans;
    sa[u].vis = true;
    ans = sa[u].end;
    for (auto &ed : sa[u].next) {
      int v = ed.second;
      ans += f(v);
    }
    return ans;
  }
};
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> s;
  suffixAutomaton sa(s);
  cout << sa.go() << "\n";
}