from collections import defaultdict n=int(input()) d=defaultdict(int) lis=[] for _ in range(n): s=list(input()) lis.append(s) for i in range(len(s)): tmp=s[:i]+['.']+s[i+1:] tmp=''.join(tmp) d[tmp]+=1 for s in lis: ans=0 for i in range(len(s)): tmp=s[:i]+['.']+s[i+1:] tmp=''.join(tmp) ans+=d[tmp]-1 print(ans)