#include <bits/stdc++.h>
using namespace std;
int n;
char s[100005];
struct SaNode {
  int link, len, nrAp;
  int sons[26];
} sa[3 * 100005];
int last, cnt;
void addCharToSa(int c) {
  int crt = (++cnt);
  sa[crt].len = sa[last].len + 1;
  sa[crt].nrAp = 1;
  for (; last != -1 && sa[last].sons[c] == 0; last = sa[last].link)
    sa[last].sons[c] = crt;
  if (last == -1) {
    sa[crt].link = 0;
    last = crt;
    return;
  }
  int x = sa[last].sons[c];
  if (sa[last].len + 1 == sa[x].len)
    sa[crt].link = x;
  else {
    int clone = (++cnt);
    sa[clone].len = sa[last].len + 1;
    sa[clone].link = sa[x].link;
    sa[x].link = sa[crt].link = clone;
    sa[clone].nrAp = 0;
    for (int i = 0; i < 26; ++i) sa[clone].sons[i] = sa[x].sons[i];
    for (; last != -1 && sa[last].sons[c] == x; last = sa[last].link)
      sa[last].sons[c] = clone;
  }
  last = crt;
}
bool Comp(int a, int b) { return sa[a].len > sa[b].len; }
void buildSa() {
  sa[0].link = -1;
  for (int i = 0; i < n; ++i) addCharToSa(s[i] - 'a');
  n = cnt;
  int ord[3 * 100005];
  for (int i = 1; i <= n; ++i) ord[i] = i;
  sort(ord + 1, ord + n + 1, Comp);
  for (int i = 1; i <= n; ++i) {
    int x = ord[i];
    sa[sa[x].link].nrAp += sa[x].nrAp;
  }
}
int main() {
  scanf("%s", s);
  n = strlen(s);
  buildSa();
  long long sol = 0;
  for (int i = 1; i <= n; ++i) {
    int x = sa[i].nrAp;
    sol += 1LL * x * (x + 1) / 2 * (sa[i].len - sa[sa[i].link].len);
  }
  printf("%I64d\n", sol);
  return 0;
}
