#include<bits/stdc++.h>
using namespace std;
const int N=1000010;
int n,sz,ch[N][26],val[N],c[26],pos[N],fm[N],fa[N],ans;
char s[N];
int ins(char *s){
	int len=strlen(s),tmp=0;
	for(int i=0;i<len;++i){
		if(!ch[tmp][s[i]-'a']){
			ch[tmp][s[i]-'a']=++sz;
			fa[sz]=tmp;fm[sz]=s[i]-'a';
		}
		tmp=ch[tmp][s[i]-'a'];
	}
	val[tmp]=1;
	return tmp;
}
void query(int tmp){
	for(int i=0;i<26;++i)c[i]=0;
	do{
		c[fm[tmp]]=1;tmp=fa[tmp];
		for(int i=0;i<26;++i)if(c[i]&&val[ch[tmp][i]])ans++;
	}while(tmp);
}
int main(){
//	freopen("B.in","r",stdin);
//	freopen("B.out","w",stdout);
	scanf("%d",&n);
	for(int i=1,len;i<=n;++i){
		scanf("%s",s);
		len=strlen(s);
		reverse(s,s+len);
		pos[i]=ins(s);
	}
	for(int i=1;i<=n;++i)query(pos[i]);
	ans-=n;
	cout<<ans<<endl;
	return 0;
} 