13381338 SUSTech Online Judge
Problem 1338 --[Easy] Aquaman‘s Dating

1338: [Easy] Aquaman‘s Dating

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 639  Solved: 235
[Submit][Status][Web Board]

Description

Dateri is a well known aquaman and he has n girl friends. Each girl's name contains only lowercase letters and the \(i_{th}\)  girl's name is \(s_i\). Girls will break up with Dateri if he incorrectly spells the prefix and suffix of her name when they are dating. Dateri is greedy and he don't want to lose any girlfriend. So he wants to remember a longest common prefix and a longest common suffix of their names. Please find the product of the length of the longest common prefix and the length of the longest common suffix of these strings.

Input

The first line is the integer n \(( 1 \leq n \leq 1000 )\). 

The following n lines contains one string \(s_i\) \((1 \leq |s_i| \leq 1000, 1 \leq i \leq n )\).

Output

One line an integer, representing the answer.

Sample Input

3
aacbb
aaabb
aabbb

Sample Output

4

HINT

Source

 

[Submit][Status]