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 max_n = 100010;
char s[max_n];
long long h[max_n];
long long gn[max_n];
int id[max_n];
int c[max_n];
int tid[max_n];
int tc[max_n];
int cnt[max_n];
const long long g = 3731;
void suffixArray(int len) {
  for (int i = 0; i < len; i++) {
    id[i] = i;
    cnt[(unsigned char)s[i]]++;
  }
  for (int i = 1; i < 255; i++) {
    cnt[i] += cnt[i - 1];
  }
  for (int i = 0; i < len; i++) {
    id[(--cnt[(unsigned char)s[i]])] = i;
  }
  c[id[0]] = 0;
  for (int i = 1; i < len; i++) {
    if (s[id[i - 1]] == s[id[i]]) {
      c[id[i]] = c[id[i - 1]];
    } else {
      c[id[i]] = c[id[i - 1]] + 1;
    }
  }
  for (int h = 0; (1 << h) < len; h++) {
    int d = (1 << h);
    for (int i = 0; i < len; i++) {
      tid[i] = ((id[i]) - (d) < 0 ? (id[i]) + (len) - (d) : (id[i]) - (d));
    }
    memset(cnt, 0, sizeof(int) * len);
    for (int i = 0; i < len; i++) {
      cnt[c[tid[i]]]++;
    }
    for (int i = 1; i < len; i++) {
      cnt[i] += cnt[i - 1];
    }
    for (int i = len - 1; i >= 0; i--) {
      id[--cnt[c[tid[i]]]] = tid[i];
    }
    tc[id[0]] = 0;
    for (int i = 1; i < len; i++) {
      bool eq = 1;
      if (c[id[i - 1]] == c[id[i]] &&
          c[((id[i - 1]) + (d) < len ? (id[i - 1]) + (d)
                                     : (id[i - 1]) + (d) - (len))] ==
              c[((id[i]) + (d) < len ? (id[i]) + (d)
                                     : (id[i]) + (d) - (len))]) {
        eq = 1;
      } else {
        eq = 0;
      }
      tc[id[i]] = tc[id[i - 1]] + (eq ? 0 : 1);
    }
    memcpy(c, tc, sizeof(int) * len);
  }
}
struct H {
  int x, h;
  void init(int x, int h) {
    this->x = x;
    this->h = h;
  }
} a[max_n];
long long geth(int i, int len) { return h[i] - gn[len] * h[i + len]; }
int main() {
  scanf("%s", &s);
  int n = strlen(s);
  s[n] = ' ';
  suffixArray(n + 1);
  gn[0] = 1;
  for (int i = 1; i <= n; i++) {
    gn[i] = gn[i - 1] * g;
  }
  for (int i = n + 2; i-- > 0;) {
    h[i] = h[i + 1] * g + s[i];
  }
  long long res = 0;
  a[0].init(1, n - id[1]);
  int u = 0;
  id[n + 1] = n;
  for (int i = 2; i <= n + 1; i++) {
    int cnt = 0, ai = id[i - 1], bi = id[i], len = min(n - ai, n - bi);
    for (int j = 65536; j >= 1; j >>= 1) {
      if (j <= len) {
        if (geth(ai, j) == geth(bi, j)) {
          ai += j;
          bi += j;
          cnt += j;
          len -= j;
        }
      }
    }
    while (u >= 0 && a[u].h > cnt) {
      long long k = (i - a[u].x);
      if (u && a[u - 1].h >= cnt) {
        res += ((k * (k + 1)) >> 1LL) * (a[u].h - a[u - 1].h);
        u--;
      } else {
        res += ((k * (k + 1)) >> 1LL) * (a[u].h - cnt);
        a[u].h = cnt;
      }
    }
    if (u >= 0 && a[u].h == n - id[i]) continue;
    ++u;
    a[u].init(i, n - id[i]);
  }
  cout << res;
  return 0;
}