# 二重ループはできない、各Siの一字替えを辞書化 from collections import defaultdict N = int(input()) S = [] dic = defaultdict(int) for i in range(N): s = input() S.append(s) for j in range(len(s)): temp = s[:j]+'*'+s[j+1:] dic[temp] += 1 #print(S) #print(dic) for s in S: count = 0 for j in range(len(s)): temp = s[:j]+'*'+s[j+1:] count += dic[temp] ans = count-len(s) print(ans)