{"raw_statement":[{"iden":"statement","content":"Given a complete undirected graph of $n$ vertices and $n$ strings $s_1, s_2, \\cdots, s_n$, the weight of edge connecting vertices $i$ and $j$ is equal to the length of the longest common substring (LCS) between $s_i$ and $s_j$. Compute the maximum total weight of any spanning tree on this graph.\n\nA substring of a string can be obtained by removing some (possibly zero) characters from the beginning and/or the end of that string. For example, ``maca``, ``aca`` and ``cau`` are all substrings of ``macau``, while ``acu`` is not."},{"iden":"input","content":"There is only one test case in each test file.\n\nThe first line of the input contains one integer $n$ ($1 \\leq n \\leq 2 \\times 10^6$) indicating the number of vertices and strings.\n\nFor the following $n$ lines, the $i$-th line contains one string $s_i$ ($1 \\le |s_i| \\le 2 \\times 10^6$) consisting only of lowercase English letters.\n\nIt's guaranteed that the sum of lengths of all strings will not exceed $2 \\times 10^6$."},{"iden":"output","content":"Output one line containing one integer indicating the answer."}],"translated_statement":null,"sample_group":[["4\nicpc\nmacau\nregional\ncontest","4"],["3\nababa\nbabab\naba","7"]],"show_order":[],"formal_statement":null,"simple_statement":null,"has_page_source":false}