#Lutece1972. 统计串的个数

统计串的个数

Migrated from Lutece 1972 统计串的个数

All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.

Description

给出字符串可重集SS

任意选出两个SS中的字符串aabb,再任意选出aa的前缀aa'bb的前缀bb',连接成为c=a+bc=a'+b'

请问有多少个不同的cc

Input

第一行一个n(n10000)n(n \le 10000),代表SS集合大小 接下来nn个串,代表SS的第ii个串 数据保证每个串均由小写字母组成,并且每个串长度小于等于3030

Output

一个数表示不同的cc的个数

Samples

输入数据 1

2
ab
ac

输出数据 1

9

输入数据 2

3
ab
bc
ca

输出数据 2

33

Resources

2018 UESTC ACM Training for Search Algorithm and String