import sys input = sys.stdin.readline class Node: def __init__(self): self.num = 0 self.next = [None] * 27 class Trie: def __init__(self): self.root = Node() def add(self, lis): last = self.root for i in lis: if(last.next[i] is None): last.next[i] = Node() last = last.next[i] last.num += 1 def search(self, lis): last = self.root for i in lis: if(last.next[i] is None): return 0 last = last.next[i] return last.num n = int(input()) user = [] trie = Trie() for i in range(n): s = input().rstrip() l = [ord(c) - ord('a') for c in s] user.append(list(l)) cl = l[:]; cl[0] = 26 trie.add(cl) for j in range(1, len(cl)): cl[j - 1] = l[j - 1] cl[j] = 26 trie.add(cl) for l in user: ans = 0 cl = l[:]; cl[0] = 26 ans += trie.search(cl) - 1 for j in range(1, len(cl)): cl[j - 1] = l[j - 1] cl[j] = 26 ans += trie.search(cl) - 1 print(ans)