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>
#pragma GCC optimize("Ofast", "unroll-loops", "no-stack-protector")
using namespace std;
template <class T>
struct rge {
  T b, e;
};
template <class T>
rge<T> range(T i, T j) {
  return rge<T>{i, j};
}
template <class T>
auto dud(T *x) -> decltype(cerr << *x, 0);
template <class T>
char dud(...);
struct debug {
  template <class T>
  debug &operator<<(const T &) {
    return *this;
  }
};
string second;
struct SuffixAutomaton {
  vector<map<char, int> > trie;
  vector<int> link, len, occ;
  vector<bool> done;
  vector<long long> mem;
  int last;
  SuffixAutomaton() { last = newNode(); }
  int newNode() {
    trie.push_back({}), link.push_back(-1), len.push_back(0), occ.push_back(0),
        mem.push_back(0), done.push_back(false);
    return int(trie.size()) - 1;
  }
  void extend(char c) {
    int u = newNode();
    len[u] = len[last] + 1;
    occ[u] = 1;
    int p = last;
    while (p != -1 && !trie[p].count(c)) {
      trie[p][c] = u;
      p = link[p];
    }
    if (p == -1)
      link[u] = 0;
    else {
      int q = trie[p][c];
      if (len[p] + 1 == len[q])
        link[u] = q;
      else {
        int clone = newNode();
        occ[clone] = 0;
        len[clone] = len[p] + 1;
        trie[clone] = trie[q];
        link[clone] = link[q];
        while (p != -1 && trie[p][c] == q) {
          trie[p][c] = clone;
          p = link[p];
        }
        link[q] = link[u] = clone;
      }
    }
    last = u;
  }
  void occurs() {
    vector<int> who;
    for (auto u = (1) - ((1) > (int(trie.size())));
         u != int(trie.size()) - ((1) > (int(trie.size())));
         u += 1 - 2 * ((1) > (int(trie.size()))))
      who.push_back(u);
    sort(begin(who), end(who), [&](int u, int v) { return len[u] > len[v]; });
    for (int u : who) occ[link[u]] += occ[u];
  }
  long long g(long long x) { return x * (x + 1LL) / 2LL; }
  long long dp(int u) {
    if (trie[u].empty()) return 0LL;
    long long &ans = mem[u];
    if (!done[u]) {
      ans = 0LL;
      done[u] = true;
      for (auto [c, v] : trie[u]) ans += dp(v) + g(occ[v]);
    }
    return ans;
  }
  void print() {
    for (auto u = (0) - ((0) > (int(trie.size())));
         u != int(trie.size()) - ((0) > (int(trie.size())));
         u += 1 - 2 * ((0) > (int(trie.size()))))
      for (auto [c, v] : trie[u]) debug() << u << " " << v << " " << c << '\n';
    for (auto u = (0) - ((0) > (int(trie.size())));
         u != int(trie.size()) - ((0) > (int(trie.size())));
         u += 1 - 2 * ((0) > (int(trie.size()))))
      debug() << u << " -> " << link[u] << ": " << occ[u] << '\n';
  }
};
int main() {
  cin.tie(0)->sync_with_stdio(0), cout.tie(0);
  while (cin >> second) {
    SuffixAutomaton sam;
    for (auto c : second) sam.extend(c);
    sam.occurs();
    cout << sam.dp(0) << '\n';
  }
  return 0;
}