import sys from collections import defaultdict as dfd input = sys.stdin.readline n = int(input()) d = dfd(int) user = [] for _ in [0]*n: s = input().rstrip() user.append(s) for i in range(len(s)): t = ''.join([s[:i],'.',s[(i+1):]]) d[t] += 1 for s in user: ans = 0 for i in range(len(s)): t = ''.join([s[:i],'.',s[(i+1):]]) ans += d[t] - 1 print(ans)