Interesting language#4674

Interesting language

2 seconds
256 megabytes
Hard

In their study of the ancient Bytean language, scientists discovered a fascinating aspect: the language utilizes only the first letters of the modern Latin alphabet. This peculiarity results in many pairs of words being quite similar. While preparing a research report, the scientists encountered the following task.

Consider all the words in the language, numbered starting from . Let S_i represent the -th word, with its length denoted as L_i. The task is to determine the number of quadruples of indices (i, j, a, b) that satisfy these conditions:

Refer to the example for further clarification.

Your task is to assist the scientists in calculating these statistics.

Input

The first line contains an integer , representing the number of words in the ancient Bytean language.

The following lines each contain one word of the Bytean language. Each word is non-empty and consists only of lowercase Latin letters from "a" to "l". All words are distinct. The total length of all words combined does not exceed 10^6.

Output

Output a single integer, which is the number of quadruples of indices that meet the specified conditions.

Examples

Example 1

Loading
Loading