"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

class TRIE{
  constructor(){
    this.tree = [{last:false}];
  }
  search(s){
    var id = 0, tr = this.tree;
    for(var i = 0; i < s.length; i++){
      if(tr[id][s[i]] === undefined)return false;
      id = tr[id][s[i]];
    }
    return tr[id].last;
  }
  add(s){
    var id = 0, tr = this.tree, i = 0;
    for(; i < s.length; i++){
      if(tr[id][s[i]] === undefined)break;
      id = tr[id][s[i]];
    }
    for(; i < s.length; i++){
      id = tr[id][s[i]] = tr.length;
      tr.push({last:false});
    }
    tr[id].last = true;
  }
  searchAndAdd(s){
    var id = 0, tr = this.tree, i = 0;
    for(; i < s.length; i++){
      if(tr[id][s[i]] === undefined)break;
      id = tr[id][s[i]];
    }
    if(i === s.length){
      if(tr[id].last)return true;
      tr[id].last = true;
      return false;
    }
    for(; i < s.length; i++){
      id = tr[id][s[i]] = tr.length;
      tr.push({last:false});
    }
    tr[id].last = true;
    return false;
  }
  next(id,s){
    var tr = this.tree;
    if(tr[id][s] === undefined){
      id = tr[id][s] = tr.length;
      tr.push({last:false});
    }else id = tr[id][s];
    return id;
  }
}

var myOut = main();
if(myOut !== undefined)console.log(String(myOut));

function main(){
  var n = next();
  var s = nexts(n,1).map(a=>a.split("").reverse().map(a=>a.charCodeAt()-97)).sort((a,b)=>a.length-b.length);
  var ans = 0;
  var st = {};
  var tr = new TRIE();
  var az = xArray(0,26);
  for(var i = 0; i < n; i++){
    var t = s[i];
    var id = 0;
    for(var j = 0; j < t.length-1; j++){
      if(st[id])for(var k = 0; k < st[id].length; k++){
        az[st[id][k]]++;
      }
      if(az[t[j]])ans += az[t[j]], az[t[j]] = 0;
      id = tr.next(id,t[j]);
    }
    if(az[t[j]])ans += az[t[j]], az[t[j]] = 0;
    if(st[id])st[id].push(t[j]);else st[id] = [t[j]];
    az = az.fill(0);
  }
  return ans;
}