require 'rational'

n=gets.to_i
s=ARGF.map{|a|a.chomp}

memo = s.map{|s|s.reverse}.sort
#p memo
count=0
memo.each{|x|
    prefix=x[0...x.size-1]
    index = memo.bsearch_index{|s| prefix <= s}
    #p [x,index]
    memo[index...memo.size].each{|t|
        if ! t.start_with?(prefix)
            break
        end
        if x!=t && t[prefix.size...t.size].include?(x[-1])
            #p [x,t]
            count += 1
        end
        }
}

p count