#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
#define PB push_back
#define ar2 array<int, 2>
typedef long long LL;
const LL P = 998244353;
const int N = 2e5+5;
mt19937 rng(time(0));

int n, last[N][26];
string s[N];
LL ans = 0;

int main(){
	ios::sync_with_stdio(false); cin.tie(0);
	
	cin>>n;
	rep(i,1,n){
		cin>>s[i];
		int sz = s[i].size();
		rep(j,0,sz/2-1) swap(s[i][j],s[i][sz-1-j]);
	}
	sort(s+1,s+n+1);
	
	memset(last,0,sizeof last);
	rep(i,1,n){
		int sz = s[i].size();
		rep(j,0,sz-1) last[i][s[i][j]-'a'] = j+1;
	}
	
	rep(i,1,n){
		int l = 1, r = n, sz = s[i].size();
		rep(j,0,sz-2){
			int l1 = l, r1 = i;
			l = i;
			while(l1<=r1){
				int mid = (l1+r1)>>1;
				if((int)s[mid].size()>=sz && s[mid][j]==s[i][j])
					r1 = mid-1, l = mid;
				else
					l1 = mid+1;
			}
			l1 = i, r1 = r;
			r = i;
			while(l1<=r1){
				int mid = (l1+r1)>>1;
				if((int)s[mid].size()>=sz && s[mid][j]==s[i][j])
					l1 = mid+1, r = mid;
				else
					r1 = mid-1;
			}
		}
		
		char ch = s[i][sz-1];
		rep(j,l,r)
			if(last[j][ch-'a'] >= sz){
				//cerr<<s[i]<<" "<<s[j]<<" "<<last[j][ch-'a']<<endl;
				ans++;
			}
	}
	cout<<ans-n<<endl;
	return 0;
}