Problem: You are given a string s. Each pair of numbers l and r that fulfill the condition 1 ≤ l ≤ r ≤ |s|, correspond to a substring of the string s, starting in the position l and ending in the position r (inclusive).

Let's define the function of two strings F(x, y) like this. We'll find a list of such pairs of numbers for which the corresponding substrings of string x are equal to string y. Let's sort this list of pairs according to the pair's first number's increasing. The value of function F(x, y) equals the number of non-empty continuous sequences in the list.

For example: F(babbabbababbab, babb) = 6. The list of pairs is as follows:

(1, 4), (4, 7), (9, 12)

Its continuous sequences are: 

  * (1, 4)
  * (4, 7)
  * (9, 12)
  * (1, 4), (4, 7)
  * (4, 7), (9, 12)
  * (1, 4), (4, 7), (9, 12)



Your task is to calculate for the given string s the sum F(s, x) for all x, that x belongs to the set of all substrings of a string s.

Input

The only line contains the given string s, consisting only of small Latin letters (1 ≤ |s| ≤ 105).

Output

Print the single number — the sought sum.

Please do not use the %lld specificator to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specificator.

Examples

Input

aaaa


Output

20


Input

abcdef


Output

21


Input

abacabadabacaba


Output

188

Note

In the first sample the function values at x equal to "a", "aa", "aaa" and "aaaa" equal 10, 6, 3 and 1 correspondingly.

In the second sample for any satisfying x the function value is 1.

Solution (in JAVA):

Solution:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.Deque;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.ArrayDeque;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Rustam Musin (t.me/musin_acm)
 */
public class Main {
  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    InputReader in = new InputReader(inputStream);
    OutputWriter out = new OutputWriter(outputStream);
    DStroka solver = new DStroka();
    solver.solve(1, in, out);
    out.close();
  }

  static class DStroka {
    public void solve(int testNumber, InputReader in, OutputWriter out) {
      String s = in.next();
      long answer = new DStroka.Solve(s).solve();
      out.print(answer);
    }

    static long sum(long n) {
      return n * (n + 1) / 2;
    }

    static class Solve {
      int n;
      char[] s;
      int[] order;
      int[] type;
      int[] lcp;

      Solve(String s) {
        s += "$";
        this.s = s.toCharArray();
        n = s.length();
      }

      long solve() {
        initSuffixArray();
        initLCP();
        DS ds = new DS();
        for (int i = 1; i < n; i++) ds.update(i);
        return ds.finish();
      }

      void updateTypes(int len) {
        int[] type2 = new int[n];
        type2[order[0]] = 0;
        for (int i = 1, j = 0; i < n; i++) {
          int left1 = type[order[i]];
          int left2 = type[order[i - 1]];
          int right1 = type[(order[i] + len) % n];
          int right2 = type[(order[i - 1] + len) % n];
          if (left1 != left2 || right1 != right2) j++;
          type2[order[i]] = j;
        }
        System.arraycopy(type2, 0, type, 0, n);
      }

      void countSort(int typeCount, int len) {
        int[] count = new int[typeCount];
        for (int t : type) count[t]++;
        for (int i = 0, j = 0; i < typeCount; i++) {
          int x = count[i];
          count[i] = j;
          j += x;
        }
        int[] order2 = new int[n];
        for (int x : order) order2[count[type[x]]++] = x;
        System.arraycopy(order2, 0, order, 0, n);
        updateTypes(len);
      }

      void initSuffixArray() {
        order = new int[n];
        type = new int[n];
        for (int i = 0; i < n; i++) order[i] = i;
        for (int i = 0; i < n; i++) type[i] = s[i];
        countSort(1 << 8, 0);
        for (int len = 1, typeCount; (typeCount = type[order[n - 1]] + 1) < n; len <<= 1) {
          for (int i = 0; i < n; i++) order[i] = (order[i] - len + n) % n;
          countSort(typeCount, len);
        }
      }

      void initLCP() {
        lcp = new int[n];
        for (int i = 0, k = 0; i < n - 1; i++) {
          int pi = type[i];
          int j = order[pi - 1];
          while (s[i + k] == s[j + k]) k++;
          lcp[pi] = k;
          if (k > 0) k--;
        }
      }

      class DS {
        Deque<IntIntPair> q;
        long total = 0;

        DS() {
          q = new ArrayDeque<>();
          q.add(IntIntPair.makePair(-1, 0));
        }

        void drop(int at) {
          while (q.peekLast().first > at) {
            IntIntPair cur = q.pollLast();
            if (q.peekLast().first == cur.first) {
              q.addLast(IntIntPair.makePair(cur.first, cur.second + q.pollLast().second));
              continue;
            }
            int left = Math.max(q.peekLast().first, at) + 1;
            int right = cur.first;
            int len = right - left + 1;
            total += len * sum(cur.second);
            q.addLast(IntIntPair.makePair(left - 1, cur.second));
          }
        }

        void update(int i) {
          drop(lcp[i] - 1);
          int lastIndex = n - 2 - order[i];
          q.addLast(IntIntPair.makePair(lastIndex, 1));
        }

        long finish() {
          drop(-1);
          return total;
        }

      }

    }

  }

  static class IntIntPair implements Comparable<IntIntPair> {
    public final int first;
    public final int second;

    public static IntIntPair makePair(int first, int second) {
      return new IntIntPair(first, second);
    }

    public IntIntPair(int first, int second) {
      this.first = first;
      this.second = second;
    }

    public boolean equals(Object o) {
      if (this == o) {
        return true;
      }
      if (o == null || getClass() != o.getClass()) {
        return false;
      }

      IntIntPair pair = (IntIntPair) o;

      return first == pair.first && second == pair.second;
    }

    public int hashCode() {
      int result = first;
      result = 31 * result + second;
      return result;
    }

    public String toString() {
      return "(" + first + "," + second + ")";
    }

    public int compareTo(IntIntPair o) {
      int value = Integer.compare(first, o.first);
      if (value != 0) {
        return value;
      }
      return Integer.compare(second, o.second);
    }

  }

  static class InputReader {
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;
    private InputReader.SpaceCharFilter filter;

    public InputReader(InputStream stream) {
      this.stream = stream;
    }

    public int read() {
      if (numChars == -1) {
        throw new InputMismatchException();
      }
      if (curChar >= numChars) {
        curChar = 0;
        try {
          numChars = stream.read(buf);
        } catch (IOException e) {
          throw new InputMismatchException();
        }
        if (numChars <= 0) {
          return -1;
        }
      }
      return buf[curChar++];
    }

    public String readString() {
      int c = read();
      while (isSpaceChar(c)) {
        c = read();
      }
      StringBuilder res = new StringBuilder();
      do {
        if (Character.isValidCodePoint(c)) {
          res.appendCodePoint(c);
        }
        c = read();
      } while (!isSpaceChar(c));
      return res.toString();
    }

    public boolean isSpaceChar(int c) {
      if (filter != null) {
        return filter.isSpaceChar(c);
      }
      return isWhitespace(c);
    }

    public static boolean isWhitespace(int c) {
      return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    public String next() {
      return readString();
    }

    public interface SpaceCharFilter {
      public boolean isSpaceChar(int ch);

    }

  }

  static class OutputWriter {
    private final PrintWriter writer;

    public OutputWriter(OutputStream outputStream) {
      writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
    }

    public OutputWriter(Writer writer) {
      this.writer = new PrintWriter(writer);
    }

    public void close() {
      writer.close();
    }

    public void print(long i) {
      writer.print(i);
    }

  }
}