#include <bits/stdc++.h>
using namespace std;
const int Max_N = 1e5;
int n, cnt = 1, lst = 1, Num, lin[Max_N * 2 + 5], T[Max_N * 2 + 5][26],
       len[Max_N * 2 + 5], p[Max_N * 2 + 5], tot[Max_N * 2 + 5];
char s[Max_N + 5];
long long ans;
struct kk {
  int Id, Next;
} e[Max_N * 2 + 5];
inline void Insert(int x, int y) {
  e[++Num].Next = lin[x];
  lin[x] = Num;
  e[Num].Id = y;
}
inline void Add(int x) {
  int New = ++cnt;
  len[New] = len[lst] + 1;
  tot[New] = 1;
  for (; lst && !T[lst][x]; T[lst][x] = New, lst = p[lst])
    ;
  if (!lst)
    p[New] = 1;
  else {
    int q = T[lst][x];
    if (len[lst] + 1 == len[q])
      p[New] = q;
    else {
      int nq = ++cnt;
      p[nq] = p[q];
      p[q] = p[New] = nq;
      len[nq] = len[lst] + 1;
      for (int i = 0; i < 26; i++) T[nq][i] = T[q][i];
      for (; lst && T[lst][x] == q; T[lst][x] = nq, lst = p[lst])
        ;
    }
  }
  lst = New;
}
inline void dfs(int x) {
  for (int i = lin[x]; i; i = e[i].Next) {
    dfs(e[i].Id);
    tot[x] += tot[e[i].Id];
  }
  ans += 1ll * tot[x] * (tot[x] + 1) / 2 * (len[x] - len[p[x]]);
}
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  for (int i = 1; i <= n; i++) Add(s[i] - 'a');
  for (int i = 1; i <= cnt; i++) Insert(p[i], i);
  dfs(1);
  cout << ans << endl;
  return 0;
}
