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>
#pragma GCC optimize("Ofast")
using namespace std;
template <typename T>
void ckmn(T& a, T b) {
  a = min(a, b);
}
template <typename T>
void ckmx(T& a, T b) {
  a = max(a, b);
}
void rd(int& x) { scanf("%i", &x); }
void rd(long long& x) { scanf("%lld", &x); }
void rd(char* x) { scanf("%s", x); }
void rd(double& x) { scanf("%lf", &x); }
void rd(string& x) { scanf("%s", &x); }
template <typename T1, typename T2>
void rd(pair<T1, T2>& x) {
  rd(x.first);
  rd(x.second);
}
template <typename T>
void rd(vector<T>& x) {
  for (T& i : x) rd(i);
}
template <typename T, typename... A>
void rd(T& x, A&... args) {
  rd(x);
  rd(args...);
}
template <typename T>
void rd() {
  T x;
  rd(x);
  return x;
}
int ri() {
  int x;
  rd(x);
  return x;
}
template <typename T>
vector<T> rv(int n) {
  vector<T> x(n);
  rd(x);
  return x;
}
template <typename T>
void ra(T a[], int n, int st = 1) {
  for (int i = 0; i < n; ++i) rd(a[st + i]);
}
template <typename T1, typename T2>
void ra(T1 a[], T2 b[], int n, int st = 1) {
  for (int i = 0; i < n; ++i) rd(a[st + i]), rd(b[st + i]);
}
template <typename T1, typename T2, typename T3>
void ra(T1 a[], T2 b[], T3 c[], int n, int st = 1) {
  for (int i = 0; i < n; ++i) rd(a[st + i]), rd(b[st + i]), rd(c[st + i]);
}
void re(vector<int> E[], int m, bool dir = 0) {
  for (int i = 0, u, v; i < m; ++i) {
    rd(u, v);
    E[u].push_back(v);
    if (!dir) E[v].push_back(u);
  }
}
template <typename T>
void re(vector<pair<int, T>> E[], int m, bool dir = 0) {
  for (int i = 0, u, v; i < m; ++i) {
    T w;
    rd(u, v, w);
    E[u].push_back({v, w});
    if (!dir) E[v].push_back({u, w});
  }
}
const int N = 100050;
const int M = 2 * N;
map<char, int> go[M];
int link[M];
char s[N];
char* st[M];
int sz[M];
int cnt_leaf[M], n;
int root, tsz;
int AddNode(char* t, int len) {
  tsz++;
  st[tsz] = t;
  sz[tsz] = len;
  link[tsz] = root;
  return tsz;
}
void BuildSuffixTree() {
  root = AddNode(NULL, 0);
  link[root] = root;
  int atnode = root, atedge = 0, atlen = 0, pleaf = 0, pnode = 0;
  for (int i = 0; i <= n; i++) {
    while (1) {
      int tonode = (atedge == n || go[atnode].count(s[atedge]))
                       ? go[atnode][s[atedge]]
                       : 0;
      if (tonode && atlen >= sz[tonode]) {
        atnode = tonode;
        atedge += sz[tonode];
        atlen -= sz[tonode];
        continue;
      }
      if (!tonode) {
        assert(atedge == i);
        if (i == n) {
          cnt_leaf[atnode]++;
          if (pleaf) link[pleaf] = atnode;
          pleaf = 0;
        } else {
          int leaf = AddNode(s + i, n - i);
          cnt_leaf[leaf]++;
          go[atnode][s[i]] = leaf;
          if (pleaf) link[pleaf] = leaf;
          pleaf = leaf;
        }
        if (pnode) link[pnode] = atnode;
        pnode = 0;
      } else if (i == n || s[i] != st[tonode][atlen]) {
        int node = AddNode(st[tonode], atlen);
        st[tonode] += atlen;
        sz[tonode] -= atlen;
        go[atnode][st[node][0]] = node;
        go[node][st[tonode][0]] = tonode;
        if (i == n) {
          cnt_leaf[node]++;
          if (pleaf) link[pleaf] = node;
          pleaf = 0;
        } else {
          int leaf = AddNode(s + i, n - i);
          cnt_leaf[leaf]++;
          go[node][s[i]] = leaf;
          if (pleaf) link[pleaf] = leaf;
          pleaf = leaf;
        }
        if (pnode) link[pnode] = node;
        pnode = node;
      } else {
        if (pnode) link[pnode] = atnode;
        pnode = 0;
        atlen++;
        break;
      }
      if (atnode == root) {
        atedge++;
        if (atlen > 0)
          atlen--;
        else
          break;
      } else
        atnode = link[atnode];
    }
  }
}
long long C2(int x) { return (long long)x * (x + 1) / 2; }
long long DFS(int u) {
  long long ans = 0;
  for (auto e : go[u]) {
    int v = e.second;
    ans += DFS(v);
    cnt_leaf[u] += cnt_leaf[v];
    ans += C2(cnt_leaf[v]) * sz[v];
  }
  return ans;
}
int main() {
  scanf("%s", s);
  n = strlen(s);
  BuildSuffixTree();
  printf("%lld\n", DFS(root));
  return 0;
}