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.Collection;
import java.util.LinkedList;
import java.util.StringTokenizer;

/**
 * 123D
 * θ(|s|) time
 * θ(|s|) space
 *
 * @author artyom
 */
public class _123D implements Runnable {
    private BufferedReader in;
    private StringTokenizer tok;

    private long solve() throws IOException {
        SuffixTreeNode root = buildSuffixTree(nextToken() + '{');
        preprocess(root);
        return count(root);
    }

    private static long count(SuffixTreeNode node) {
        long cnt = ((node.isLeaf() ? node.end - 1 : node.end) - node.start) * (node.leaves + 1) * node.leaves / 2;
        if (!node.isLeaf()) {
            for (SuffixTreeNode child : node.activeChildren) {
                cnt += count(child);
            }
        }
        return cnt;
    }

    private static void preprocess(SuffixTreeNode node) {
        if (node.isLeaf()) {
            node.leaves = 1;
        } else {
            node.activeChildren = new LinkedList<>();
            for (SuffixTreeNode child : node.children) {
                if (child != null) {
                    preprocess(child);
                    node.leaves += child.leaves;
                    node.activeChildren.add(child);
                }
            }
        }
    }

    //--------------------------------------------------------------
    public static void main(String[] args) {
        new _123D().run();
    }

    @Override
    public void run() {
        try {
            in = new BufferedReader(new InputStreamReader(System.in));
            tok = null;
            System.out.print(solve());
            in.close();
        } catch (IOException e) {
            System.exit(0);
        }
    }

    private String nextToken() throws IOException {
        while (tok == null || !tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }

    @SuppressWarnings("ConstantConditions")
    private static SuffixTreeNode buildSuffixTree(CharSequence s) {
        int n = s.length();
        byte[] a = new byte[n];
        for (int i = 0; i < n; i++) {
            a[i] = (byte) (s.charAt(i) - 'a');
        }
        SuffixTreeNode root = new SuffixTreeNode(0, 0, 0, null, null);
        SuffixTreeNode node = root;
        for (int i = 0, tail = 0; i < n; i++, tail++) {
            SuffixTreeNode last = null;
            while (tail >= 0) {
                SuffixTreeNode ch = node.children[a[i - tail]];
                while (ch != null && tail >= ch.length()) {
                    tail -= ch.length();
                    node = ch;
                    ch = ch.children[a[i - tail]];
                }
                if (ch == null) {
                    node.children[a[i]] = new SuffixTreeNode(i, n, node.depth(), i, node);
                    if (last != null) {
                        last.suffixLink = node;
                    }
                    last = null;
                } else {
                    byte t = a[(int) (ch.start + tail)];
                    if (t == a[i]) {
                        if (last != null) {
                            last.suffixLink = node;
                        }
                        break;
                    } else {
                        SuffixTreeNode splitNode = new SuffixTreeNode(ch.start, ch.start + tail, node.depth(), null, node);
                        splitNode.children[a[i]] = new SuffixTreeNode(i, n, ch.depth + tail, i, splitNode);
                        splitNode.children[t] = ch;
                        ch.start += tail;
                        ch.depth += tail;
                        ch.parent = splitNode;
                        node.children[a[i - tail]] = splitNode;
                        if (last != null) {
                            last.suffixLink = splitNode;
                        }
                        last = splitNode;
                    }
                }
                if (node == root) {
                    tail--;
                } else {
                    node = node.suffixLink;
                }
            }
        }
        return root;
    }

    private static final class SuffixTreeNode {
        long depth; // The number of characters from root to this node
        long start; // Inclusive
        long end; // Exclusive
        Long position;
        SuffixTreeNode parent;
        final SuffixTreeNode[] children;
        SuffixTreeNode suffixLink;
        // Additional properties
        Collection<SuffixTreeNode> activeChildren;
        long leaves;

        private SuffixTreeNode(long start, long end, long depth, Integer position, SuffixTreeNode parent) {
            this.start = start;
            this.end = end;
            this.parent = parent;
            this.depth = depth;
            if (position == null) {
                this.position = null;
                this.children = new SuffixTreeNode[27];
            } else {
                this.position = position - depth;
                // Save some space and time
                this.children = null;
            }
        }

        boolean isLeaf() {
            return position != null;
        }

        /**
         * @return the number of characters on the edge to the parent.
         */
        final long length() {
            return end - start;
        }

        /**
         * @return the number of characters on the path from the root to this node.
         */
        final long depth() {
            return depth + end - start;
        }

        @Override
        public String toString() {
            return "(" + start + ',' + (end - 1) + ')';
        }
    }
}