require 'set'

N = gets.to_i
S = N.times.map { gets.chomp }

table = Hash.new { |h, k| h[k] = Array.new(26, 0) }
paths = Array.new(N) { [] }
is_end = Hash.new(false)

nxt = 1

S.map(&:reverse).each_with_index do |s, id|
  node_id = 0

  s.chars.each_with_index do |ch, idx|
    paths[id] << node_id
    cid = ch.ord - 'a'.ord

    if table[node_id][cid] == 0
      table[node_id][cid] = nxt
      nxt += 1
    end

    node_id = table[node_id][cid]
  end

  is_end[node_id] = true
end

ans = 0

paths.each_with_index do |path, idx|
  s = S[idx].reverse
  set = Set.new
  n = path.size

  (n - 1).downto(0) do |i|
    nid = path[i]
    set.add(s[i])

    set.each do |ch|
      id = table[nid][ch.ord - 'a'.ord]
      ans += 1 if is_end[id]
    end
  end
end

puts ans - N
