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;
template <class T>
void dbs(string str, T t) {
  cerr << str << " : " << t << "\n";
}
template <class T, class... S>
void dbs(string str, T t, S... s) {
  int idx = str.find(',');
  cerr << str.substr(0, idx) << " : " << t << ",";
  dbs(str.substr(idx + 1), s...);
}
template <class S, class T>
ostream& operator<<(ostream& os, const pair<S, T>& p) {
  return os << "(" << p.first << ", " << p.second << ")";
}
template <class T>
ostream& operator<<(ostream& os, const vector<T>& p) {
  os << "[ ";
  for (auto& it : p) os << it << " ";
  return os << "]";
}
template <class T>
ostream& operator<<(ostream& os, const set<T>& p) {
  os << "[ ";
  for (auto& it : p) os << it << " ";
  return os << "]";
}
template <class S, class T>
ostream& operator<<(ostream& os, const map<S, T>& p) {
  os << "[ ";
  for (auto& it : p) os << it << " ";
  return os << "]";
}
template <class T>
void prc(T a, T b) {
  cerr << "[";
  for (T i = a; i != b; ++i) {
    if (i != a) cerr << ", ";
    cerr << *i;
  }
  cerr << "]\n";
}
const int N = 100010;
const int LOG = 18;
string s;
int n;
int p[LOG][N];
pair<pair<int, int>, int> vec[N];
pair<int, int> suff[N];
int save[N];
int lcp(int a, int b) {
  int temp = a;
  for (int i = LOG - 1; i >= 0 and max(a, b) < n; i--) {
    if (p[i][a] == p[i][b]) {
      a += (1 << i), b += (1 << i);
    }
  }
  return a - temp;
}
int main() {
  cin >> s;
  n = int(s.size());
  for (int i = (int)(0); i <= (int)(n - 1); i++) {
    p[0][i] = s[i];
  }
  for (int i = (int)(1); i <= (int)(LOG - 1); i++) {
    for (int j = (int)(0); j <= (int)(n - 1); j++) {
      if (j + (1 << (i - 1)) >= n) {
        vec[j] = make_pair(make_pair(p[i - 1][j], -1), j);
      } else {
        vec[j] =
            make_pair(make_pair(p[i - 1][j], p[i - 1][j + (1 << (i - 1))]), j);
      }
    }
    sort(vec, vec + n);
    for (int j = (int)(1); j <= (int)(n - 1); j++) {
      if (vec[j].first == vec[j - 1].first) {
        p[i][vec[j].second] = p[i][vec[j - 1].second];
      } else {
        p[i][vec[j].second] = j;
      }
    }
  }
  for (int i = (int)(0); i <= (int)(n - 1); i++) {
    suff[i] = make_pair(p[LOG - 1][i], i);
  }
  sort(suff, suff + n);
  for (int i = (int)(0); i <= (int)(n - 2); i++) {
    save[i] = lcp(suff[i].second, suff[i + 1].second);
  }
  long long answer1 = 0;
  stack<pair<long long, long long>> s1;
  s1.push(make_pair(save[0], 1));
  long long currSum = save[0];
  for (int i = (int)(1); i <= (int)(n - 1); i++) {
    answer1 += currSum;
    long long x = save[i], cnt = 1;
    if (i == n - 1) break;
    while (!s1.empty() and s1.top().first > x) {
      currSum -= s1.top().first * s1.top().second;
      cnt += s1.top().second;
      s1.pop();
    }
    s1.push(make_pair(save[i], cnt));
    currSum += x * cnt;
  }
  cout << answer1 + (n * 1LL * (n + 1)) / 2 << "\n";
  return 0;
}