#include <bits/stdc++.h>
using namespace std;
const long double eqs = 1e-6;
const long long max_ = 1e5 + 7;
const int mod = 100000;
const int inf = 1e9 + 7;
const long long INF = 1e18;
inline int read() {
  int ret = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -f;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') ret = ret * 10 + ch - '0', ch = getchar();
  return ret * f;
}
inline void write(int x) {
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
int len, siz;
struct {
  int next[27], Len, Fail;
  long long cnt;
} sam[max_ << 1];
char S[max_];
inline void getsam() {
  len = strlen(S + 1);
  sam[0].Fail = -1;
  int fa = 0;
  for (int i = 1; i <= len; i++) {
    int cur = ++siz;
    sam[cur].cnt = 1;
    sam[cur].Len = sam[fa].Len + 1;
    int now = fa;
    while (now != -1 && !sam[now].next[S[i] - 'a']) {
      sam[now].next[S[i] - 'a'] = cur;
      now = sam[now].Fail;
    }
    if (now == -1) {
      sam[cur].Fail = 0;
    } else {
      int to = sam[now].next[S[i] - 'a'];
      if (sam[now].Len + 1 == sam[to].Len) {
        sam[cur].Fail = to;
      } else {
        int clone = ++siz;
        sam[clone] = sam[to];
        sam[clone].cnt = 0;
        sam[clone].Len = sam[now].Len + 1;
        while (now != -1 && sam[now].next[S[i] - 'a'] == to) {
          sam[now].next[S[i] - 'a'] = clone;
          now = sam[now].Fail;
        }
        sam[to].Fail = sam[cur].Fail = clone;
      }
    }
    fa = cur;
  }
}
int sor[max_], id[max_ << 1];
long long ans = 0;
inline long long cal(long long a, long long b) {
  if (a % 2)
    return b / 2 * a;
  else
    return a / 2 * b;
}
inline void getcishu() {
  for (int i = 1; i <= siz; i++) sor[sam[i].Len]++;
  for (int i = 1; i <= len; i++) sor[i] += sor[i - 1];
  for (int i = siz; i >= 1; i--) id[sor[sam[i].Len]--] = i;
  for (int i = siz; i >= 1; i--) {
    sam[sam[id[i]].Fail].cnt += sam[id[i]].cnt;
    ans += (sam[id[i]].Len - sam[sam[id[i]].Fail].Len) *
           cal(sam[id[i]].cnt, sam[id[i]].cnt + 1);
  }
}
signed main() {
  cin >> S + 1;
  getsam();
  getcishu();
  cout << ans;
  return 0;
}
