local mfl, mce = math.floor, math.ceil
local mmi, mma = math.min, math.max
local bls, brs = bit.lshift, bit.rshift
local SegTree = {}
SegTree.updateAll = function(self)
  for i = self.stagenum - 1, 1, -1 do
    local cnt = bls(1, i - 1)
    for j = 1, cnt do
      self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])
    end
  end
end
SegTree.create = function(self, n, func, emptyvalue)
  self.func, self.emptyvalue = func, emptyvalue
  local stagenum, mul = 1, 1
  self.stage = {{}}
  while mul < n do
    mul, stagenum = mul * 2, stagenum + 1
    self.stage[stagenum] = {}
  end
  self.stagenum = stagenum
  self.left_stage = {}
  for i = 1, n do
    local sp, sz = 1, bls(1, stagenum - 1)
    while(i - 1) % sz ~= 0 do
      sp, sz = sp + 1, brs(sz, 1)
    end
    self.left_stage[i] = sp
  end
  self.sz_stage = {}
  local tmp, sp = 1, stagenum
  for i = 1, n do
    if tmp * 2 == i then tmp, sp = tmp * 2, sp - 1 end
    self.sz_stage[i] = sp
  end
  for i = 1, mul do self.stage[stagenum][i] = emptyvalue end
  self:updateAll()
end
SegTree.getRange = function(self, left, right)
  if left == right then return self.stage[self.stagenum][left] end
  local stagenum = self.stagenum
  local ret = self.emptyvalue
  while left <= right do
    local stage = mma(self.left_stage[left], self.sz_stage[right - left + 1])
    local sz = bls(1, stagenum - stage)
    ret = self.func(ret, self.stage[stage][1 + brs(left - 1, stagenum - stage)])
    left = left + sz
  end
  return ret
end
SegTree.update = function(self, idx)
  for i = self.stagenum - 1, 1, -1 do
    local dst = brs(idx + 1, 1)
    local rem = dst * 4 - 1 - idx
    self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])
    idx = dst
  end
end
SegTree.setValue = function(self, idx, value, silent)
  local prv = self.stage[self.stagenum][idx]
  self.stage[self.stagenum][idx] = value
  if prv ~= value and not silent then
    self:update(idx)
  end
end
SegTree.right_bound_lcp = function(self, val, left, right)
  local retpos = left - 1
  local l, r = left, right
  local stage = mma(self.left_stage[left], self.sz_stage[right - left + 1])
  local stagenum = self.stagenum
  while true do
    local sz = bls(1, stagenum - stage)
    if val <= self.stage[stage][mce(l / sz)] then
      retpos = l + sz - 1
      if retpos == right then break end
      if l + sz <= r then
        l = l + sz
        stage = mma(self.left_stage[l], self.sz_stage[r - l + 1])
      else break end
    else
      if sz ~= 1 then stage, r = stage + 1, l + sz - 2
      else break end
    end
  end
  return retpos + 1
end
SegTree.new = function(n, func, emptyvalue)
  local obj = {}
  setmetatable(obj, {__index = SegTree})
  obj:create(n, func, emptyvalue)
  return obj
end

local n = io.read("*n", "*l")
local prefix = {}
local suffix = {}
local idx_prefix = {}
for i = 1, n do
  local s = io.read():reverse()
  if 1 < #s then
    prefix[i] = s:sub(1, #s - 1)
    suffix[i] = s:sub(#s, #s)
  else
    prefix[i] = ""
    suffix[i] = s
  end
  idx_prefix[i] = i
end

table.sort(idx_prefix, function(a, b) return prefix[a] < prefix[b] end)
local idx_prefix_inv = {}
for i = 1, n do idx_prefix_inv[i] = i end
for i = 1, n do
  idx_prefix_inv[idx_prefix[i]] = i
end

local st_lcp = SegTree.new(n, mmi, 0)

for i = 1, n - 1 do
  local src, dst = idx_prefix[i], idx_prefix[i + 1]
  local z = mmi(#prefix[src], #prefix[dst])
  local l = 0
  for j = 1, z do
    if prefix[src]:byte(j) == prefix[dst]:byte(j) then l = j
    else break
    end
  end
  st_lcp:setValue(i, l, true)
end
st_lcp:updateAll()

local st_char_by_prefix = {}
local function addfunc(a, b) return a + b end
for i = 1, 26 do
  st_char_by_prefix[i] = SegTree.new(n, addfunc, 0)
end

local ret = 0
local idx_length = {}
for i = 1, n do idx_length[i] = i end
table.sort(idx_length, function(a, b) return #prefix[a] < #prefix[b] end)
local cur_maxlen = #prefix[idx_length[n]]
for i = n, 1, -1 do
  local original_idx = idx_length[i]
  if #prefix[original_idx] < cur_maxlen then
    for j = i + 1, n do
      local tgt = idx_length[j]
      local tgt_prefix_idx = idx_prefix_inv[tgt]
      for k = #prefix[original_idx] + 1, cur_maxlen do
        local v = prefix[tgt]:byte(k) - 96
        st_char_by_prefix[v]:setValue(tgt_prefix_idx, 1)
      end
    end
    cur_maxlen = #prefix[original_idx]
  end
  local prefix_idx = idx_prefix_inv[original_idx]
  local rb = st_lcp:right_bound_lcp(#prefix[original_idx], prefix_idx, n)
  rb = mmi(n, rb)
  local suf = suffix[original_idx]:byte() - 96
  if prefix_idx <= rb then
    ret = ret + st_char_by_prefix[suf]:getRange(prefix_idx, rb)
  end
  st_char_by_prefix[suf]:setValue(prefix_idx, 1)
end
print(ret)
