CF616F Expensive Strings

Description

You are given $ n $ strings $ t_{i} $ . Each string has cost $ c_{i} $ . Let's define the function of string ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF616F/a2be2e6a84d9d8ad3e2e42357554f4328caffa73.png), where $ p_{s,i} $ is the number of occurrences of $ s $ in $ t_{i} $ , $ |s| $ is the length of the string $ s $ . Find the maximal value of function $ f(s) $ over all strings. Note that the string $ s $ is not necessarily some string from $ t $ .

Input Format

The first line contains the only integer $ n $ ( $ 1

Output Format

Print the only integer $ a $ — the maximal value of the function $ f(s) $ over all strings $ s $ . Note one more time that the string $ s $ is not necessarily from $ t $ .