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.util.LinkedList;
import java.util.Arrays;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.List;
import java.io.BufferedReader;
import java.math.BigInteger;
import java.io.PrintStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Comparator;
import java.io.IOException;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author shu_mj @ http://shu-mj.com
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		Scanner in = new Scanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskJ solver = new TaskJ();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskJ {
    Scanner in;
    PrintWriter out;

    public void solve(int testNumber, Scanner in, PrintWriter out) {
        this.in = in;
        this.out = out;
        run();
    }

    void run() {
        String s = in.next();
        SuffixArray sa = new SuffixArray(s.toCharArray());
        sa.buildHs();
        int n = s.length();
        UnionFindSet uf = new UnionFindSet(n + 1);
        List<P>[] ps = new List[n];
        for (int i = 0; i < n; i++) {
            ps[i] = new LinkedList<P>();
        }
        for (int i = 0; i < n; i++) {
            ps[sa.hs[i]].add(new P(sa.si[i], sa.si[i + 1]));
        }
        int[] cnt = new int[n + 1];
        Arrays.fill(cnt, 1);
        cnt[n] = 0;
        long res = 0;
        long crt = 1;
        for (int i = n - 1; i >= 0; i--) {
            for (P p : ps[i]) {
                int l = uf.find(p.x);
                int r = uf.find(p.y);
                crt -= (long) cnt[l] * (cnt[l] + 1) / 2;
                crt -= (long) cnt[r] * (cnt[r] + 1) / 2;
                uf.pre[l] = r;
                cnt[r] += cnt[l];
                crt += (long) cnt[r] * (cnt[r] + 1) / 2;
            }
            res += crt;
        }
        out.println(res);
    }
    class P {
        int x;
        int y;

        P(int x, int y) {
            this.x = x;
            this.y = y;
        }
    }
}

class Scanner {
    BufferedReader br;
    StringTokenizer st;

    public Scanner(InputStream in) {
        br = new BufferedReader(new InputStreamReader(in));
        eat("");
    }

    private void eat(String s) {
        st = new StringTokenizer(s);
    }

    public String nextLine() {
        try {
            return br.readLine();
        } catch (IOException e) {
            return null;
        }
    }

    public boolean hasNext() {
        while (!st.hasMoreTokens()) {
            String s = nextLine();
            if (s == null)
                return false;
            eat(s);
        }
        return true;
    }

    public String next() {
        hasNext();
        return st.nextToken();
    }

}

class SuffixArray {
    public int n;
    public char[] cs;
    public int[] si, is;// ソート後と元のインデックスの対応

    public int[] indexSort(int[] is) {
        int[] c = new int[128];
        for (int i : is) c[i]++;
        for (int i = 1; i < 128; i++) c[i] += c[i - 1];
        int n = is.length;
        int[] si = new int[n];
        for (int i = n - 1; i >= 0; i--) si[--c[is[i]]] = i;
        return si;
    }

    public SuffixArray(char[] t) {
        n = t.length;
        cs = new char[n + 1];
        System.arraycopy(t, 0, cs, 0, n);
        cs[n] = 0;// 番兵(他の全ての値より小さくすること)
        is = new int[n + 1];
        for (int i = 0; i <= n; i++) is[i] = cs[i];
        si = indexSort(is);
        int[] a = new int[n + 1], b = new int[n + 1];
        for (int h = 0; ; ) {
            for (int i = 0; i < n; i++) {
                int x = si[i + 1], y = si[i];
                b[i + 1] = b[i];
                if (is[x] > is[y] || is[x + h] > is[y + h]) b[i + 1]++;
            }
            for (int i = 0; i <= n; i++) is[si[i]] = b[i];
            if (b[n] == n) break;
            h = Math.max(1, h << 1);
            for (int k = h; k >= 0; k -= h) {
                Arrays.fill(b, 0);
                b[0] = k;
                for (int i = k; i <= n; i++) b[is[i]]++;
                for (int i = 0; i < n; i++) b[i + 1] += b[i];
                for (int i = n; i >= 0; i--) {
                    a[--b[si[i] + k > n ? 0 : is[si[i] + k]]] = si[i];
                }
                int[] tmp = si; si = a; a = tmp;
            }
        }
    }

    public int[] hs;// hs[i]:=ソート後のsuffix のi とi+1 のLCP

    public void buildHs() {
        hs = new int[n + 1];
        for (int i = 0, h = 0; i < n; i++) {
            for (int j = si[is[i] - 1]; cs[i + h] == cs[j + h]; h++) ;
            hs[is[i] - 1] = h;
            if (h > 0) h--;
        }
    }

}

class UnionFindSet {
    public int[] pre;

    public UnionFindSet(int n) {
        pre = new int[n];
        for (int i = 0; i < n; i++) pre[i] = i;
    }

    public int find(int x) {
        if (pre[x] != x) pre[x] = find(pre[x]);
        return pre[x];
    }

}