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:
// practice with rainboy
import java.io.*;
import java.util.*;

public class CF123D extends PrintWriter {
	CF123D() { super(System.out, true); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		CF123D o = new CF123D(); o.main(); o.flush();
	}

	byte[] cc;
	int[] sa, a0, a1, kk, pp;
	Integer[] ii;
	void compress(int n) {
		for (int i = 0, a = 1; i < n; i++)
			a0[sa[i]] = i + 1 == n || a0[sa[i + 1]] != a0[sa[i]] || a1[sa[i + 1]] != a1[sa[i]] ? a++ : a;
	}
	void init(int n) {
		sa = new int[n]; a0 = new int[n]; a1 = new int[n];
		kk = new int[n + 1]; pp = new int[n];
		ii = new Integer[n];
		for (int i = 0; i < n; i++)
			ii[i] = i;
		Arrays.sort(ii, (i, j) -> cc[i] - cc[j]);
		for (int i = 0; i < n; i++)
			sa[i] = ii[i];
		for (int i = 0; i < n; i++)
			a0[i] = cc[i];
		compress(n);
	}
	void sort(int[] ii, int[] jj, int[] aa, int n) {
		Arrays.fill(kk, 0);
		for (int i = 0; i < n; i++) {
			int a = aa[i];
			kk[a]++;
		}
		for (int a = 0, k, l = 0; a <= n; a++) {
			k = kk[a]; kk[a] = l; l += k;
		}
		for (int i = 0; i < n; i++) {
			int j = ii[i], a = aa[j];
			jj[kk[a]++] = j;
		}
	}
	void build(int n) {
		init(n);
		for (int m = 1; m < n; m <<= 1) {
			for (int i = 0; i < n; i++)
				a1[i] = i + m < n ? a0[i + m] : 0;
			sort(sa, pp, a1, n);
			sort(pp, sa, a0, n);
			compress(n);
		}
		for (int i = 0, p = 0; i < n; i++, p--) {
			int a = a0[i] - 1;
			if (a + 1 < n) {
				int j = sa[a + 1];
				if (p < 0)
					p = 0;
				while (i + p < n && cc[i + p] == cc[j + p])
					p++;
				pp[a] = p;
			}
		}
		pp[n - 1] = -1;
	}
	void main() {
		cc = sc.next().getBytes();
		int n = cc.length;
		build(n);
		Arrays.sort(ii, (i, j) -> pp[i] - pp[j]);
		int[] ll = new int[n];
		int[] rr = new int[n];
		for (int a = 0; a < n; a++)
			ll[a] = rr[a] = a;
		long ans = (long) n * (n + 1) / 2, cnt = 0;
		for (int p = n - 1, i = n - 1, a; p > 0; p--) {
			while (i > 0 && pp[a = ii[i]] == p) {
				cnt += (long) (rr[a] - ll[a] + 1) * (rr[a + 1] - ll[a + 1] + 1);
				int l = ll[a], r = rr[a + 1]; rr[l] = r; ll[r] = l;
				i--;
			}
			ans += cnt;
		}
		println(ans);
	}
}