#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

var_to_int = [*'a'..'z'].each_with_object({}).with_index do |(cur, sum), index|
  sum[cur] = 2 ** index
end

N = get_int
S = []
N.times do |i|
  S[i] = gets.chomp
end

S.sort! { |a, b| a.length <=> b.length }

count = 0
hash = Hash.new { |h,k| h[k] = 0 }
S.each do |s|
  set = 0
  0.step(s.length-1) do |i|
    set |= var_to_int[s[i]]
    rest = s[(i+1)..]
    if i == 0
      hash[rest] |= var_to_int[s[i]]
    else
      test = 1
      v = hash[rest]
      while test <= v || test <= set
        count += 1 if v & test > 0 && set & test > 0
        test *= 2
      end
      # count += counting_1bits(hash[rest] & set)
    end
  end
end

p count

# count = 0
# hash = Hash.new { |h,k| h[k] = Set.new }
# S.each do |s|
#   set = Set.new
#   0.step(s.length-1) do |i|
#     set.add(s[i])
#     rest = s[(i+1)..]
#     count += (hash[rest] & set).length
#   end
#
#   first, *rest = s.split('')
#   hash[rest.join].add(first)
# end
#
# p count
