#include <bits/stdc++.h>
const int MAXN = 1e6 + 19;
int root, ind;
int son[MAXN][26], cnt[MAXN][26], vist[26];
void insert(int &node, char *str, int len){
	if(!node) node = ++ind;
//	std::printf("insert %c in %d\n", *str, node);
	if(len > 1)
		insert(son[node][*str - 'a'], str - 1, len - 1);
	vist[*str - 'a'] = 1;
	for(int i = 0; i < 26; ++i)
		if(vist[i])
			++cnt[node][i];
}
int query(int node, char *str, int len){
	if(!node) return 0;
	if(len == 1)
		return cnt[node][*str - 'a'];
	else return query(son[node][*str - 'a'], str - 1, len - 1);
}
int n;
char s[MAXN], *beg[MAXN], *end[MAXN];
int main(){
	std::scanf("%d", &n);
	end[0] = s;
	for(int i = 1; i <= n; ++i){
		beg[i] = end[i - 1];
		std::scanf("%s", beg[i]); int len = std::strlen(beg[i]);
		end[i] = beg[i] + len;
		std::memset(vist, 0, sizeof vist);
		insert(root, end[i] - 1, len);
	}
//	for(int i = 0; i < 26; ++i) std::printf("%c%d\n", 'a' + i, cnt[root][i]);
	long long ans = 0ll;
	for(int i = 1; i <= n; ++i){
//		std::printf("%d\n", query(root, end[i] - 1, end[i] - beg[i]));
		ans += query(root, end[i] - 1, end[i] - beg[i]);
	}
	std::printf("%lld\n", ans-n);
}