from collections import Counter n = int(input()) s = [input() for _ in range(n)] l = [Counter() for _ in range(10)] for st in s: for i in range(len(st)): l[i][st[:i] + st[i + 1:]] += 1 for st in s: ans = 0 for i in range(len(st)): ans += l[i][st[:i] + st[i + 1:]] - 1 print(ans)