tc=int(raw_input())
dic={chr(x):{} for x in range(ord('A'),ord('z')+1) }
tot=0
while(tc>0):
	tc-=1
	st=raw_input()
	rev=st[::-1]
	if(dic[rev[0]].get(rev)!=None):
		tot+=dic[rev[0]][rev]
	
	if(dic[st[0]].get(st)==None):
		dic.get(st[0])[st]=1
	else:
		dic.get(st[0])[st]+=1
print tot