#include <bits/stdc++.h>
void Emsawy() {}
using namespace std;
struct state {
  int len, link;
  map<char, int> next;
};
const int MAXLEN = 100000 + 5;
struct SA {
  state st[MAXLEN * 2];
  int fpos[MAXLEN * 2];
  int sz, last;
  void sa_init() {
    sz = last = 0;
    st[0].len = 0;
    st[0].link = -1;
    ++sz;
  }
  void sa_extend(char c) {
    int cur = sz++;
    st[cur].len = st[last].len + 1;
    fpos[cur] = st[cur].len - 1;
    int p;
    for (p = last; p != -1 && !st[p].next.count(c); p = st[p].link)
      st[p].next[c] = cur;
    if (p == -1)
      st[cur].link = 0;
    else {
      int q = st[p].next[c];
      if (st[p].len + 1 == st[q].len)
        st[cur].link = q;
      else {
        int clone = sz++;
        st[clone].len = st[p].len + 1;
        st[clone].next = st[q].next;
        st[clone].link = st[q].link;
        fpos[clone] = fpos[q];
        for (; p != -1 && st[p].next[c] == q; p = st[p].link)
          st[p].next[c] = clone;
        st[q].link = st[cur].link = clone;
      }
    }
    last = cur;
  }
} sa;
int finals[MAXLEN * 2];
int dfs(int nd) {
  if (finals[nd] != -1) return finals[nd];
  finals[nd] = sa.st[nd].next.find('$') != sa.st[nd].next.end();
  for (auto v : sa.st[nd].next) {
    finals[nd] += dfs(v.second);
  }
  return finals[nd];
}
int main() {
  Emsawy();
  string s;
  while (cin >> s) {
    s += '$';
    sa.sa_init();
    for (int i = 0; i < s.size(); i++) {
      sa.sa_extend(s[i]);
    }
    memset(finals, -1, sizeof finals);
    dfs(0);
    int cur = 0;
    long long ans = 0;
    for (int i = 1; i < sa.sz; i++) {
      cur = i;
      long long tmp = finals[cur];
      long long si = (sa.st[cur].len - sa.st[sa.st[cur].link].len);
      ans += (tmp * (tmp + 1) / 2) * si;
    }
    cout << ans << endl;
  }
  return 0;
}
