n = int(raw_input())
s={}
for i in range(n):
	key = raw_input()
	if key in s:
		s[key].append(i)
	else:
		s[key] = [i]

count = 0

for key in s.keys():
	#print key
	if key[::-1] in s and key in s:
		value = s[key]
		m = len(value)
		rev_list = s[key[::-1]]
		n = len(rev_list)
		i, j = 0, 0
		while i<m and j<n:
			if value[i]<rev_list[j]:
				count += n-j
				i+=1
			else:
				count += m-i
				j+=1
		del s[key]
		#print s.keys()
		del s[key[::-1]]
		#print s.keys()
	

print(count)