using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	const double eps=1e-11;
	static void Main(){
		Sc sc=new Sc();
		var n=sc.I;
		var t=new (string,int[])[n];
		for(int i = 0;i<n;i++) {
			t[i].Item1=sc.S;
			t[i].Item1=string.Join("",t[i].Item1.Reverse());
			t[i].Item2=new int[t[i].Item1.Length+1];
			for(int j = t[i].Item1.Length-1;j>=0;j--) {
				t[i].Item2[j]|=t[i].Item2[j+1]|(1<<(t[i].Item1[j]-'a'));
			}
		}
		Array.Sort(t,(u,v)=>u.Item1.Length-v.Item1.Length);
		var tt=new Trie('a','z');
		for(int i = 0;i<n;i++) {tt.Add(t[i]);}
		Console.WriteLine(tt.ans);
	}
}
public class Trie{
	static private int o,n;
	public int cnt=1;
	public long ans=0;
	public Nd root;
	public List<Nd> lih;
	public class Nd{
		public Nd[] ar;
		public int hb=0;
		public int c,f=0,n;
		public bool b=false;
		public Nd(int c,int f,int n){this.c=c-o;this.f=f;this.n=n;}
		public override string ToString(){
			var t="n:"+n.ToString("d2")+" f:"+f.ToString()+" c:"+(char)(c+o)+" ";
			if(ar==null){t+=new string('-',Trie.n);}
			else{for(int j=0;j<ar.Length;j++){t+=(b&&ar[j]!=null?(char)(j+o):'-');}}
			t+=" "+Binary(hb,Trie.n);
			return t;
		}
		public string Binary(long a,int b){
			string s=Convert.ToString(a,2);
			return (b>s.Length?new string('0',b-s.Length):"")+s;
		}
	}
	public Trie(int a,int z){
		n=z-a+1;
		o=a;
		root=new Nd(a-1,0,0);
		lih=new List<Nd>();
		lih.Add(root);
	}
	public void Add((string,int[]) t){
		var r=root;
		for(int j = 0;j<t.Item1.Length;j++) {
			if(j==0){
				ans+=Pc(r.hb&(t.Item2[j]|(1<<(t.Item1[t.Item1.Length-1]-o))));
			}
			else{
				ans+=Pc(r.hb&t.Item2[j]);
			}
			if(t.Item1.Length==1){
				r.hb|=1<<(t.Item1[0]-o);
				break;
			}
			else if(j==t.Item1.Length-1){
				r.hb|=1<<(t.Item1[t.Item1.Length-1]-o);
			}
			if(!r.b){r.ar=new Nd[n];r.b=true;}
			if(r.ar[t.Item1[j]-o]==null){lih.Add(r=r.ar[t.Item1[j]-o]=new Nd(t.Item1[j],j+1,lih.Count));cnt++;}
			else{r=r.ar[t.Item1[j]-o];}
		}
	}
	private int Pc(int n){
		n-=(n>>1)&0x55555555;
		n=(n&0x33333333)+((n>>2)&0x33333333);
		return ((n+(n>>4)&0xF0F0F0F)*0x1010101)>>24;
    }
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),int.Parse);}
	public int[] Ia3(int a){return Array.ConvertAll((Console.ReadLine()+" "+a.ToString()).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),long.Parse);}
	public long[] La3(int a){return Array.ConvertAll((Console.ReadLine()+" "+a.ToString()).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 356504