#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cstdio>
#include <set>
#define LL long long
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
const int maxn=1000010;
int G[maxn][26];
bool flg[maxn];
int n,ans,nxt=1;
int main(){
	cin>>n;
	vector<string>in(n);
	vector<vector<int> >p(n);
	for(int sta=0;sta<n;sta++){
		cin>>in[sta];
		string&s=in[sta];
		reverse(s.begin(),s.end());
		int node=0;
		for(char ch:s){
			int x=ch-'a';
			p[sta].pb(node);
			if(G[node][x]==0)G[node][x]=nxt++;
			node=G[node][x];
		}
		flg[node]=1;
	}
	for(int sta=0;sta<n;sta++){
		set<int>lst;
		string&s=in[sta];
		for(int i=(int)s.length()-1;i>=0;--i){
			int node=p[sta][i];
			lst.insert(s[i]);
			for(char ch:lst)ans+=flg[G[node][ch-'a']];
		}
	}
	cout<<ans-n<<endl;
}
