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;
vector<vector<int> > c;
vector<int> sort_cyclic_shifts(const string &s) {
  int n = s.size();
  const int alphabet = 256;
  vector<int> p(n), cnt(alphabet, 0);
  c.clear();
  c.emplace_back();
  c[0].resize(n);
  for (int i = 0; i < n; i++) cnt[s[i]]++;
  for (int i = 1; i < alphabet; i++) cnt[i] += cnt[i - 1];
  for (int i = 0; i < n; i++) p[--cnt[s[i]]] = i;
  c[0][p[0]] = 0;
  int classes = 1;
  for (int i = 1; i < n; i++) {
    if (s[p[i]] != s[p[i - 1]]) classes++;
    c[0][p[i]] = classes - 1;
  }
  vector<int> pn(n), cn(n);
  cnt.resize(n);
  for (int h = 0; (1 << h) < n; h++) {
    for (int i = 0; i < n; i++) {
      pn[i] = p[i] - (1 << h);
      if (pn[i] < 0) pn[i] += n;
    }
    fill(cnt.begin(), cnt.end(), 0);
    for (int i = 0; i < n; i++) cnt[c[h][pn[i]]]++;
    for (int i = 1; i < classes; i++) cnt[i] += cnt[i - 1];
    for (int i = n - 1; i >= 0; i--) p[--cnt[c[h][pn[i]]]] = pn[i];
    cn[p[0]] = 0;
    classes = 1;
    for (int i = 1; i < n; i++) {
      pair<int, int> cur = {c[h][p[i]], c[h][(p[i] + (1 << h)) % n]};
      pair<int, int> prev = {c[h][p[i - 1]], c[h][(p[i - 1] + (1 << h)) % n]};
      if (cur != prev) ++classes;
      cn[p[i]] = classes - 1;
    }
    c.push_back(cn);
  }
  return p;
}
vector<int> suffix_array_construction(string s) {
  s += "!";
  vector<int> sorted_shifts = sort_cyclic_shifts(s);
  sorted_shifts.erase(sorted_shifts.begin());
  return sorted_shifts;
}
int compare(int i, int j, int n, int k) {
  pair<int, int> a = {c[k][i], c[k][(i + 1 - (1 << k)) % n]};
  pair<int, int> b = {c[k][j], c[k][(j + 1 - (1 << k)) % n]};
  return a == b ? 0 : a < b ? -1 : 1;
}
int lcp(int i, int j) {
  int log_n = c.size() - 1;
  int ans = 0;
  for (int k = log_n; k >= 0; k--) {
    if (c[k][i] == c[k][j]) {
      ans += 1 << k;
      i += 1 << k;
      j += 1 << k;
    }
  }
  return ans;
}
vector<int> lcp_construction(const string &s, const vector<int> &sa) {
  int n = s.size();
  vector<int> rank(n, 0);
  vector<int> lcp(n - 1, 0);
  for (int i = 0; i < n; i++) rank[sa[i]] = i;
  for (int i = 0, k = 0; i < n; i++) {
    if (rank[i] == n - 1) {
      k = 0;
      continue;
    }
    int j = sa[rank[i] + 1];
    while (i + k < n && j + k < n && s[i + k] == s[j + k]) k++;
    lcp[rank[i]] = k;
    if (k) k--;
  }
  return lcp;
}
const int N = 1e5 + 7, K = 18;
int st[N][K];
int lg[N];
void pre() {
  lg[1] = 0;
  for (int i = 2; i < N; i++) lg[i] = lg[i / 2] + 1;
}
void build(const vector<int> &lcp) {
  int n = lcp.size();
  for (int i = 0; i < n; i++) st[i][0] = lcp[i];
  for (int k = 1; k < K; k++)
    for (int i = 0; i < n; i++) {
      st[i][k] = st[i][k - 1];
      int nxt = i + (1 << (k - 1));
      if (nxt >= n) continue;
      st[i][k] = min(st[i][k], st[nxt][k - 1]);
    }
}
int get(int l, int r) {
  int k = lg[r - l + 1];
  return min(st[l][k], st[r - (1 << k) + 1][k]);
}
pair<int, int> f(int l, int r, int tar) {
  int lo = l, hi = r;
  while (lo < hi) {
    int mid = (lo + hi + 1) / 2;
    int k = get(l, mid - 1);
    if (k > tar)
      lo = mid;
    else
      hi = mid - 1;
  }
  if (lo == l) return pair<int, int>(l, -1);
  return pair<int, int>(lo, get(l, lo - 1));
}
int main() {
  pre();
  string s;
  cin >> s;
  int n = s.size();
  vector<int> sa = suffix_array_construction(s);
  vector<int> lcp = lcp_construction(s, sa);
  build(lcp);
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    int cur = (i ? lcp[i - 1] : 0);
    int len = n - sa[i];
    int hi = n - 1;
    while (cur < len) {
      pair<int, int> pr = f(i, hi, cur);
      hi = pr.first;
      if (hi == i) pr.second = len;
      int nw = pr.second - cur;
      int cnt = hi - i + 1;
      ans += 1LL * nw * cnt * (cnt + 1) / 2;
      cur = pr.second;
      hi = pr.first;
    }
  }
  cout << ans << endl;
}