#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3fffffff;
const long long mod = 1000000007;
const int maxn = 1e5 + 100;
int sa[maxn];
int t1[maxn], t2[maxn], c[maxn];
int rk[maxn], height[maxn];
void build_sa(int s[], int n, int m) {
  int i, j, p, *x = t1, *y = t2;
  for (i = 0; i < m; i++) c[i] = 0;
  for (i = 0; i < n; i++) c[x[i] = s[i]]++;
  for (i = 1; i < m; i++) c[i] += c[i - 1];
  for (i = n - 1; i >= 0; i--) sa[--c[x[i]]] = i;
  for (j = 1; j <= n; j <<= 1) {
    p = 0;
    for (i = n - j; i < n; i++) y[p++] = i;
    for (i = 0; i < n; i++)
      if (sa[i] >= j) y[p++] = sa[i] - j;
    for (i = 0; i < m; i++) c[i] = 0;
    for (i = 0; i < n; i++) c[x[y[i]]]++;
    for (i = 1; i < m; i++) c[i] += c[i - 1];
    for (i = n - 1; i >= 0; i--) sa[--c[x[y[i]]]] = y[i];
    swap(x, y);
    p = 1;
    x[sa[0]] = 0;
    for (i = 1; i < n; i++)
      x[sa[i]] = y[sa[i - 1]] == y[sa[i]] && y[sa[i - 1] + j] == y[sa[i] + j]
                     ? p - 1
                     : p++;
    if (p >= n) break;
    m = p;
  }
}
void getHeight(int s[], int n) {
  int i, j, k = 0;
  for (i = 0; i <= n; i++) rk[sa[i]] = i;
  for (i = 0; i < n; i++) {
    if (k) k--;
    j = sa[rk[i] - 1];
    while (s[i + k] == s[j + k]) k++;
    height[rk[i]] = k;
  }
}
char s[maxn];
int a[maxn];
int st[maxn], pre[maxn];
long long ans[maxn];
int main() {
  scanf("%s", s);
  int l = (int)strlen(s);
  for (int i = 0; i < l; i++) a[i] = s[i] - 'a' + 1;
  a[l] = 0;
  build_sa(a, l + 1, 60);
  getHeight(a, l);
  long long res = 1ll * l * (l + 1) / 2;
  int top = 0;
  ans[1] = 0;
  st[0] = 1;
  for (int i = 2; i < l + 1; i++) {
    if (!height[i]) {
      st[top] = i, ans[i] = 0;
      continue;
    }
    while (top && height[st[top]] >= height[i]) top--;
    ans[i] = ans[st[top]] + 1ll * (i - st[top]) * height[i];
    st[++top] = i;
    res += ans[i];
  }
  printf("%lld\n", res);
  return 0;
}
