#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
const int mod = 1e9 + 7;
const int SN = 2e6 + 10;
const int SM = 26;
int siz[SN];
struct SAM {
  int trans[SN][SM], link[SN], maxlen[SN], pre, scnt;
  SAM() { pre = scnt = 1; }
  void update(int id) {
    int cur = ++scnt;
    siz[cur] = 1;
    maxlen[cur] = maxlen[pre] + 1;
    int u = pre;
    pre = cur;
    for (; u && !trans[u][id]; u = link[u]) trans[u][id] = cur;
    if (!u)
      link[cur] = 1;
    else {
      int x = trans[u][id];
      if (maxlen[x] == maxlen[u] + 1)
        link[cur] = x;
      else {
        int nc = ++scnt;
        maxlen[nc] = maxlen[u] + 1;
        link[nc] = link[x];
        link[cur] = link[x] = nc;
        memcpy(trans[nc], trans[x], sizeof(trans[x]));
        for (; u && trans[u][id] == x; u = link[u]) trans[u][id] = nc;
      }
    }
  }
} T;
vector<int> g[N];
long long ans = 0;
void dfs(int x) {
  for (int to : g[x]) {
    dfs(to);
    siz[x] += siz[to];
  }
  ans += 1ll * (siz[x] + 1) * siz[x] / 2 * (T.maxlen[x] - T.maxlen[T.link[x]]);
}
char s[SN];
int main() {
  scanf("%s", s);
  int len = strlen(s);
  for (int i = 0; i < len; i++) T.update(s[i] - 'a');
  for (int i = 2; i <= T.scnt; i++) g[T.link[i]].push_back(i);
  dfs(1);
  printf("%lld", ans);
}
