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 State {
  State *pre, *go[26];
  int len, minlen, cnt;
  void clear() {
    pre = 0;
    len = 0;
    cnt = 0;
    minlen = 0;
    memset(go, 0, sizeof(go));
  }
} * root, *last;
State sam[200100 << 1], *cur, *b[200100 << 1];
int cnt[200100];
void init() {
  cur = sam;
  root = last = cur++;
  root->clear();
}
void extend(int w) {
  State *p = last;
  State *np = cur++;
  np->clear();
  np->len = p->len + 1;
  while (p && !p->go[w]) p->go[w] = np, p = p->pre;
  if (p == 0)
    np->pre = root;
  else {
    State *q = p->go[w];
    if (p->len + 1 == q->len)
      np->pre = q;
    else {
      State *nq = cur++;
      nq->clear();
      memcpy(nq->go, q->go, sizeof(q->go));
      nq->len = p->len + 1;
      nq->pre = q->pre;
      q->pre = nq;
      np->pre = nq;
      while (p && p->go[w] == q) p->go[w] = nq, p = p->pre;
    }
  }
  last = np;
}
char s[200100];
int main() {
  scanf("%s", s);
  init();
  int len = strlen(s);
  for (int i = 0; i < len; ++i) extend(s[i] - 'a');
  memset(cnt, 0, sizeof(cnt));
  for (State *p = sam; p != cur; ++p) cnt[p->len]++;
  for (int i = 1; i <= len; ++i) cnt[i] += cnt[i - 1];
  int tot = cnt[len];
  for (State *p = sam; p != cur; ++p) b[--cnt[p->len]] = p;
  long long ans = 0;
  State *p = root;
  for (int i = 0; i < len; ++i) {
    p = p->go[s[i] - 'a'];
    p->cnt = 1;
  }
  for (int i = tot - 1; i >= 1; --i) {
    b[i]->minlen = b[i]->pre->len + 1;
    b[i]->pre->cnt += b[i]->cnt;
    ans +=
        1LL * (b[i]->len - b[i]->minlen + 1) * b[i]->cnt * (b[i]->cnt + 1) / 2;
  }
  printf("%lld\n", ans);
  return 0;
}