#include <bits/stdc++.h>
using namespace std;


#define int long long

const int N = 2e5 + 7;

string str[N]; 



int nxt[1000001][27], ptr = 1;


void insrt(string &s) {
	int cur = 1;
	for(auto ch: s) {
		if(!nxt[cur][ch - 'a']) {
			nxt[cur][ch - 'a'] = ++ptr;
 		}
 		cur = nxt[cur][ch - 'a'];
	}
	nxt[cur][26]++;
}

int32_t main() {
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n; cin >> n;
	for(int i = 1; i <= n; i++) {
		cin >> str[i];
		reverse(str[i].begin(), str[i].end());
		insrt(str[i]);
	}
	int ans = 0;
	for(int i = 1; i <= n; i++) {
		vector <int> f(26, -1);
		int cur = 1;
		for(int j = 0; j < str[i].size(); j++) {
			f[str[i][j] - 'a'] = j;
		}
		for(int j = 0; j < 26; j++) if(f[j] > -1) {
			ans += nxt[nxt[cur][j]][26];
		}
		for(int j = 0; j < str[i].size(); j++) {
			cur = nxt[cur][str[i][j] - 'a'];
			for(int k = 0; k < 26; k++) {
				if(f[k] > j)
				ans += nxt[nxt[cur][k]][26];
			}
		}
		--ans;
		//cout << i << " " << ans << endl;
	}
	cout << ans << endl;
}