#include <bits/stdc++.h>
using namespace std;
class SuffixAutomaton {
 private:
  struct Node {
    int len, link;
    bool clone = false;
    map<char, int> next;
  };
  int last = 0;
  vector<Node> dag;

 public:
  SuffixAutomaton(const string& str = "") {
    dag.reserve(str.size() * 2);
    dag.emplace_back();
    dag[0].len = 0;
    dag[0].link = -1;
    last = 0;
    for (char chr : str) extend(chr);
  }
  void extend(char chr) {
    int now = dag.size();
    dag.emplace_back();
    dag[now].len = dag[last].len + 1;
    int p = last;
    while (p != -1 && !dag[p].next.count(chr)) {
      dag[p].next[chr] = now;
      p = dag[p].link;
    }
    if (p == -1)
      dag[now].link = 0;
    else {
      int q = dag[p].next[chr];
      if (dag[q].len == dag[p].len + 1)
        dag[now].link = q;
      else {
        int clone = dag.size();
        dag.emplace_back();
        dag[clone].clone = true;
        dag[clone].len = dag[p].len + 1;
        dag[clone].next = dag[q].next;
        dag[clone].link = dag[q].link;
        while (p != -1 && dag[p].next[chr] == q) {
          dag[p].next[chr] = clone;
          p = dag[p].link;
        }
        dag[q].link = dag[now].link = clone;
      }
    }
    last = now;
  }
  int64_t solve() {
    vector<int64_t> dp(dag.size());
    vector<int> nodes(dag.size());
    for (int i = 0; i < (int)dag.size(); i++) nodes[i] = i;
    sort(nodes.begin(), nodes.end(),
         [&](int x, int y) { return dag[x].len > dag[y].len; });
    for (int node : nodes)
      if (!dag[node].clone) dp[node] = 1;
    for (int node : nodes)
      if (dag[node].link != -1) dp[dag[node].link] += dp[node];
    vector<int> topo;
    vector<bool> vis(dag.size());
    function<void(int)> dfs = [&](int node) {
      vis[node] = true;
      for (auto nghb : dag[node].next)
        if (!vis[nghb.second]) dfs(nghb.second);
      topo.push_back(node);
    };
    dfs(0);
    reverse(topo.begin(), topo.end());
    vector<int64_t> nr(dag.size());
    nr[0] = 1;
    for (int node : topo)
      for (auto nghb : dag[node].next) nr[nghb.second] += nr[node];
    int64_t ans = 0;
    for (int i = 1; i < (int)dag.size(); i++)
      ans += nr[i] * dp[i] * (dp[i] + 1) / 2;
    return ans;
  }
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  string str;
  cin >> str;
  SuffixAutomaton sa(str);
  cout << sa.solve() << '\n';
  return 0;
}
