N = int(input()) S = [input() for _ in range(N)] from collections import defaultdict d = defaultdict(int) for s in S: for i in range(len(s)): T = s[:i] + "?" + s[i + 1:] d[T] += 1 for s in S: tmp = 0 for i in range(len(s)): T = s[:i] + "?" + s[i + 1:] tmp += d[T] - 1 print(tmp)