Binary strings#5527

Binary strings

1 second
256 megabytes
Easy

A binary string is a sequence that consists only of the characters '0' and '1'. A suffix of a string is a string obtained by removing the first (K \geq 0) characters from the original string. For example, the suffixes of the string "1001" are "1001", "001", "01", "1" and the empty string.

You are given binary strings. Find how many pairs of these strings have the property that one of the strings in the pair is a suffix of the other.

Input

The first line contains an integer (2 \leq N \leq 100\,000). Each of the following lines contains one non-empty binary string. The total length of all strings does not exceed .

Output

Output a single integer—the number of such pairs.

Examples

Example 1

Loading
Loading