#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5;
struct state {
  int len, link;
  map<char, int> next;
};
state st[2 * MAXN];
long long occ[2 * MAXN];
int terminals[2 * MAXN];
int sz, last;
void sa_init() {
  last = st[0].len = 0;
  sz = 1;
  st[0].link = -1;
}
void sa_extend(char c) {
  int k = sz++, p;
  st[k].len = st[last].len + 1;
  for (p = last; p != -1 && !st[p].next.count(c); p = st[p].link)
    st[p].next[c] = k;
  if (p == -1)
    st[k].link = 0;
  else {
    int q = st[p].next[c];
    if (st[p].len + 1 == st[q].len)
      st[k].link = q;
    else {
      int w = sz++;
      st[w].len = st[p].len + 1;
      st[w].next = st[q].next;
      st[w].link = st[q].link;
      for (; p != -1 && st[p].next[c] == q; p = st[p].link) st[p].next[c] = w;
      st[q].link = st[k].link = w;
    }
  }
  last = k;
}
void dfs(int s) {
  if (occ[s] != 0) return;
  long long o = 0;
  if (terminals[s]) o++;
  for (auto e : st[s].next) {
    dfs(e.second);
    o += occ[e.second];
  }
  occ[s] = o;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string s;
  cin >> s;
  sa_init();
  int n = s.length();
  for (long long i = 0; i < n; i++) sa_extend(s[i]);
  int p = last;
  memset(&occ, 0, sizeof(occ));
  memset(&terminals, 0, sizeof(terminals));
  while (p > 0) {
    terminals[p] = 1;
    p = st[p].link;
  }
  dfs(0);
  long long ans = 0;
  for (long long i = 1; i < 2 * n + 10; i++) {
    ans += ((occ[i] * (occ[i] + 1)) / 2) * (st[i].len - st[st[i].link].len);
  }
  cout << ans << "\n";
  return 0;
}
