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;
struct custom_hash {
  static unsigned long long splitmix64(unsigned long long x) {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(unsigned long long x) const {
    static const unsigned long long FIXED_RANDOM =
        chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};
mt19937 random_generator(
    chrono::steady_clock::now().time_since_epoch().count());
const int maxn = 1e5 + 3;
string s;
void read() { cin >> s; }
struct suffix {
  int first, second, idx;
  bool operator<(const suffix &t) const {
    if (first != t.first) return first < t.first;
    return second < t.second;
  }
  suffix() {}
  suffix(int _first, int _second, int _idx) {
    first = _first, second = _second, idx = _idx;
  }
};
int idx[maxn][19];
suffix suffixes[maxn];
int suffix_array[maxn];
int lcp(int i, int j) {
  int ans = 0;
  int sz = s.size();
  for (int k = 18; k >= 0 && i <= sz && j <= sz; k--)
    if (idx[i][k] == idx[j][k]) ans += (1 << k), i += (1 << k), j += (1 << k);
  return ans;
}
pair<int, int> tr[maxn * 4];
int a[maxn];
void merge(int v) { tr[v] = min(tr[v * 2], tr[v * 2 + 1]); }
void build(int v, int l, int r) {
  if (l == r) {
    tr[v] = {a[l], l};
    return;
  }
  int mid = (l + r) / 2;
  build(v * 2, l, mid);
  build(v * 2 + 1, mid + 1, r);
  merge(v);
}
pair<int, int> get(int v, int l, int r, int ll, int rr) {
  if (l > rr || r < ll) return {INT_MAX, INT_MAX};
  if (l >= ll && r <= rr) return tr[v];
  int mid = (l + r) / 2;
  return min(get(v * 2, l, mid, ll, rr), get(v * 2 + 1, mid + 1, r, ll, rr));
}
long long f(int l, int r) {
  if (l > r) return 0;
  if (l == r) return a[l];
  int idx = get(1, 1, (int)s.size() - 1, l, r).second;
  long long ans = f(l, idx - 1) + f(idx + 1, r);
  ans += 1ll * (idx - l + 1) * (r - idx + 1) * a[idx];
  return ans;
}
void solve() {
  int sz = s.size();
  for (int i = 1; i <= sz; i++) idx[i][0] = s[i - 1] - 'a' + 1;
  for (int j = 1; j <= 18; j++) {
    for (int i = 1; i <= sz; i++)
      suffixes[i] = suffix(
          idx[i][j - 1],
          i + (1 << (j - 1)) <= sz ? idx[i + (1 << (j - 1))][j - 1] : 0, i);
    sort(suffixes + 1, suffixes + sz + 1);
    int curr_idx = 1;
    idx[suffixes[1].idx][j] = curr_idx;
    for (int i = 2; i <= sz; i++) {
      if (suffixes[i].first != suffixes[i - 1].first ||
          suffixes[i].second != suffixes[i - 1].second)
        curr_idx++;
      idx[suffixes[i].idx][j] = curr_idx;
    }
  }
  for (int i = 1; i <= sz; i++) suffix_array[idx[i][18]] = i;
  for (int i = 1; i <= sz - 1; i++)
    a[i] = lcp(suffix_array[i], suffix_array[i + 1]);
  build(1, 1, sz - 1);
  long long ans = 1ll * sz * (sz + 1) / 2;
  ans += f(1, sz - 1);
  cout << ans << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  read();
  solve();
}