#include<cstdio>
#include<cstring>
using namespace std;
struct sd{
	int son[26],endby[26],v,f,end;
}t[1000005];
int n,m;
long long ans;
bool add[27];
char s[1000005];
inline void insert(int now,int nlen,int val) {
	t[now].v=val;
	if(!nlen) t[now].end++;
	else {
		if(t[now].son[s[nlen]-'a']) {t[t[now].son[s[nlen]-'a']].f=now;insert(t[now].son[s[nlen]-'a'],nlen-1,s[nlen]-'a');}
		else {++m;t[now].son[s[nlen]-'a']=m;t[m].f=now;insert(m,nlen-1,s[nlen]-'a');}
	}
	for(int i=0;i!=26;++i) if(add[i]) t[now].endby[i]++;
	add[val]=true;
	return;
}
int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;++i) {
		scanf("%s",s+1);
		memset(add,0,sizeof(add));
		insert(0,strlen(s+1),26);
		for(int j=strlen(s+1);j;--j) s[j]=NULL;
	}
	for(int i=1;i<=m;++i)
		ans+=(long long)t[i].end*(t[t[i].f].endby[t[i].v]-1LL);
	printf("%lld",ans);
	return 0;
}