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.*;
import java.util.Arrays;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class CF123_D_String {

    private static class SuffixAutomaton {
        int maxSize;
        int[] link;
        int[] len;
        int nodeCount;
        int last;
        int root;
        TreeMap<Character, Integer>[] to;
        boolean[] finalState;

        long[] dp;

        public SuffixAutomaton(String s) {
            int n = s.length();
            maxSize = n << 1 + 1;
            nodeCount = 1;
            last = root = 0;
            link = new int[maxSize];
            len = new int[maxSize];
            to = new TreeMap[maxSize];
            to[root] = new TreeMap<>();
            for (int i = 0; i < n; i++)
                addLetter(s.charAt(i));
            finalState = new boolean[maxSize];
            markFinalStates(last);
            dp = new long[maxSize];
            Arrays.fill(dp, -1);
        }

        void addLetter(char c) {
            int node = nodeCount++;
            len[node] = len[last] + 1;
            to[node] = new TreeMap<>();
            while (to[last].get(c) == null) {
                to[last].put(c, node);
                last = link[last];
            }
            int t = to[last].get(c);
            if (t == node)
                link[node] = 0;
            else if (len[t] == len[last] + 1)
                link[node] = t;
            else {
                int q = nodeCount++;
                len[q] = len[last] + 1;
                to[q] = new TreeMap<>(to[t]);
                link[q] = link[t];
                link[t] = link[node] = q;
                while (to[last].get(c) != null && to[last].get(c) == t) {
                    to[last].put(c, q);
                    last = link[last];
                }
            }
            last = node;
        }

        private void markFinalStates(int node) {
            while (node != root) {
                finalState[node] = true;
                node = link[node];
            }
            finalState[root] = true;
        }

        public long solve() {
            solve(root);
            long ans = 0;
            for (int node = 1; node < maxSize; node++) {
                long x = dp[node];
                if (x != -1)
                    ans += ((x * (x + 1)) >> 1) * (len[node] - len[link[node]]);
            }
            return ans;
        }

        private long solve(int node) {
            if (dp[node] != -1)
                return dp[node];
            long ans = finalState[node] ? 1 : 0;
            for (Map.Entry<Character, Integer> e : to[node].entrySet())
                ans += solve(e.getValue());
            return dp[node] = ans;
        }
    }

    public static void main(String[] args) throws IOException {
        MyScanner sc = new MyScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        SuffixAutomaton sa = new SuffixAutomaton(sc.next());
        out.println(sa.solve());
        out.flush();
        out.close();
    }

    private static class MyScanner {
        StringTokenizer st;
        BufferedReader br;

        public MyScanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public MyScanner(String filename) throws IOException {
            br = new BufferedReader(new FileReader(new File(filename)));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public double nextDouble() throws IOException {
            String x = next();
            StringBuilder sb = new StringBuilder("0");
            double res = 0, f = 1;
            boolean dec = false, neg = false;
            int start = 0;
            if (x.charAt(0) == '-') {
                neg = true;
                start++;
            }
            for (int i = start; i < x.length(); i++)
                if (x.charAt(i) == '.') {
                    res = Long.parseLong(sb.toString());
                    sb = new StringBuilder("0");
                    dec = true;
                } else {
                    sb.append(x.charAt(i));
                    if (dec)
                        f *= 10;
                }
            res += Long.parseLong(sb.toString()) / f;
            return res * (neg ? -1 : 1);
        }

        public boolean ready() throws IOException {
            return br.ready();
        }
    }
}