require 'rational'

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

memo = s.map{|s|s.reverse}.sort
memo2 = memo.map{|x| x.chars.each_with_object({}){|c,m|m[c]||=0;m[c]+=1;} }
#p memo
count=0
memo.each_with_index{|x,i|
    prefix=x[0...x.size-1]
    index = memo.bsearch_index{|s| prefix <= s}
    (index...memo.size).each{|ti|
        t=memo[ti]
        if ! t.start_with?(prefix)
            break
        end
        c=x[-1]
        if x.size != t.size && (memo2[ti][c]||0) >= memo2[i][c]
            count += 1
        end
    }
}

p count