#include <bits/stdc++.h>
using namespace std;
const int md = 1e9 + 7;
const int maxn = 1e5 + 5;
const int Size = maxn * 2;
namespace SAM {
int nxt[Size][27];
int par[Size];
int len[Size];
int cur[Size];
int pos[Size];
int g[Size];
int rt, last, tol;
int newNode(int x) {
  len[++tol] = x;
  par[tol] = 0;
  memset(nxt[tol], 0, sizeof nxt[tol]);
  return tol;
}
void init() {
  tol = 0;
  last = rt = newNode(0);
}
void add(int c) {
  int p = last;
  int np = newNode(len[p] + 1);
  while (p && !nxt[p][c]) {
    nxt[p][c] = np;
    p = par[p];
  }
  if (!p)
    par[np] = rt;
  else {
    int q = nxt[p][c];
    if (len[p] + 1 == len[q])
      par[np] = q;
    else {
      int nq = newNode(len[p] + 1);
      memcpy(nxt[nq], nxt[q], sizeof nxt[q]);
      par[nq] = par[q];
      par[q] = par[np] = nq;
      while (p && nxt[p][c] == q) {
        nxt[p][c] = nq;
        p = par[p];
      }
    }
  }
  last = np;
}
void ins(char s[]) {
  for (int i = 0; s[i]; i++) {
    add(s[i] - 'a');
  }
}
long long cal(char s[]) {
  for (int i = 0; i <= tol; i++) cur[i] = 0;
  for (int i = 1; i <= tol; i++) cur[len[i]]++;
  for (int i = 1; i <= tol; i++) cur[i] += cur[i - 1];
  for (int i = 1; i <= tol; i++) pos[cur[len[i]]--] = i;
  for (int i = 0, p = rt; s[i]; i++) {
    g[p = nxt[p][s[i] - 'a']]++;
  }
  for (int i = tol; i >= 1; i--) {
    int u = pos[i];
    g[par[u]] += g[u];
  }
  long long ans = 0;
  for (int i = 2; i <= tol; i++) {
    ans += (long long)(len[i] - len[par[i]]) * g[i] * (g[i] + 1) / 2;
  }
  return ans;
}
}  // namespace SAM
char str[maxn];
int main() {
  using namespace SAM;
  scanf("%s", str);
  init();
  ins(str);
  cout << cal(str) << '\n';
  return 0;
}
