n = input()

s = [""] * n

t = {}

for i in xrange(n):
	s[i] = raw_input()

ans = 0

for i in xrange(len(s)):
	rv = s[i][::-1]
	
	if rv in t:
		ans += t[rv]
		
	if s[i] in t:
		tmp = t[s[i]]
		t[s[i]] = tmp + 1
	else:
		t[s[i]] = 1
	
print ans