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;
const int N = 3 * (2e5 + 5);
int wa[N], wb[N], wss[N], wv[N], sa[N];
int rak[N], height[N], cal[N], n;
char s[N], ans[N], s1[N];
int cnt[N], l[N], r[N];
int c0(int *r, int a, int b) {
  return r[a] == r[b] && r[a + 1] == r[b + 1] && r[a + 2] == r[b + 2];
}
int c12(int k, int *r, int a, int b) {
  if (k == 2) return r[a] < r[b] || r[a] == r[b] && c12(1, r, a + 1, b + 1);
  return r[a] < r[b] || r[a] == r[b] && wv[a + 1] < wv[b + 1];
}
void Rsort(int *r, int *a, int *b, int n, int m) {
  for (int i = 0; i < n; i++) wv[i] = r[a[i]];
  for (int i = 0; i < m; i++) wss[i] = 0;
  for (int i = 0; i < n; i++) wss[wv[i]]++;
  for (int i = 1; i < m; i++) wss[i] += wss[i - 1];
  for (int i = n - 1; i >= 0; i--) b[--wss[wv[i]]] = a[i];
}
void dc3(int *r, int *sa, int n, int m) {
  int i, j, *rn = r + n, *san = sa + n, ta = 0, tb = (n + 1) / 3, tbc = 0, p;
  r[n] = r[n + 1] = 0;
  for (i = 0; i < n; i++)
    if (i % 3 != 0) wa[tbc++] = i;
  Rsort(r + 2, wa, wb, tbc, m);
  Rsort(r + 1, wb, wa, tbc, m);
  Rsort(r, wa, wb, tbc, m);
  for (p = 1, rn[((wb[0]) / 3 + ((wb[0]) % 3 == 1 ? 0 : tb))] = 0, i = 1;
       i < tbc; i++)
    rn[((wb[i]) / 3 + ((wb[i]) % 3 == 1 ? 0 : tb))] =
        c0(r, wb[i - 1], wb[i]) ? p - 1 : p++;
  if (p < tbc)
    dc3(rn, san, tbc, p);
  else
    for (i = 0; i < tbc; i++) san[rn[i]] = i;
  for (i = 0; i < tbc; i++)
    if (san[i] < tb) wb[ta++] = san[i] * 3;
  if (n % 3 == 1) wb[ta++] = n - 1;
  Rsort(r, wb, wa, ta, m);
  for (i = 0; i < tbc; i++)
    wv[wb[i] = ((san[i]) < tb ? (san[i]) * 3 + 1 : ((san[i]) - tb) * 3 + 2)] =
        i;
  for (i = 0, j = 0, p = 0; i < ta && j < tbc; p++)
    sa[p] = c12(wb[j] % 3, r, wa[i], wb[j]) ? wa[i++] : wb[j++];
  for (; i < ta; p++) sa[p] = wa[i++];
  for (; j < tbc; p++) sa[p] = wb[j++];
}
void calheight(int *r, int *sa, int n) {
  int i, j, k = 0;
  for (i = 1; i <= n; i++) rak[sa[i]] = i;
  for (i = 0; i < n; height[rak[i++]] = k)
    for (k ? k-- : 0, j = sa[rak[i] - 1]; r[i + k] == r[j + k]; k++)
      ;
  for (int i = n; i; i--) rak[i] = rak[i - 1];
  for (int i = n; i; i--) sa[i]++;
}
void gao() {
  stack<int> temp1, temp2;
  for (int i = 1; i <= n; i++) {
    if (i == 1) {
      temp1.push(i);
      l[i] = i;
    } else {
      while (height[temp1.top()] >= height[i]) {
        temp1.pop();
        if (temp1.empty()) break;
      }
      if (!temp1.empty())
        l[i] = temp1.top() + 1;
      else
        l[i] = 1;
      temp1.push(i);
    }
  }
  for (int i = n; i >= 1; i--) {
    if (i == n) {
      temp2.push(i);
      r[i] = i;
    } else {
      while (height[temp2.top()] >= height[i]) {
        temp2.pop();
        if (temp2.empty()) break;
      }
      if (!temp2.empty())
        r[i] = temp2.top() - 1;
      else
        r[i] = n;
      temp2.push(i);
    }
  }
}
long long a[N];
unordered_map<int, int> mp[N];
int main() {
  int t, cas = 1, k;
  scanf("%s", s + 1);
  n = strlen(s + 1);
  cal[n + 1] = 0;
  for (int i = 1; i <= n; i++) cal[i] = s[i] - 'a' + 1;
  dc3(cal + 1, sa, n + 1, 30);
  calheight(cal + 1, sa, n);
  gao();
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    if (height[i] == 0) {
      ans += n - sa[i] + 1 - max(height[i + 1], height[i]);
    } else {
      if (!mp[l[i]][r[i]]) {
        ans += 1ll * (r[i] - l[i] + 2) * (r[i] - l[i] + 3) / 2 *
               (height[i] - max(height[l[i] - 1], height[r[i] + 1]));
        mp[l[i]][r[i]] = 1;
      }
      ans += n - sa[i] + 1 - max(height[i + 1], height[i]);
    }
  }
  printf("%lld\n", ans);
  return 0;
}