#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	int N;
	cin >> N;
	vector<pair<int,string>> S;
	for (int i = 0; i < N; ++ i) {
		string s;
		cin >> s;
		S.push_back({(int)s.length(), s});
	}
	sort(S.begin(), S.end());
	map<ll, int> hoge;
	ll ans = 0;
	for (const auto& pp : S) {
		int n = pp.first;
		const string& s = pp.second;
		vector<int> a(n+1);
		for (int j = 0; j < n; ++ j) {
			a[j+1] = a[j] | (1 << (s[j]-'a'));
		}
		ll hh = 0;
		for (int j = n-1; j >= 1; -- j) {
			auto it = hoge.find(hh);
			if (it != hoge.end()) {
				ans += __builtin_popcount(it->second & a[j+1]);
			}
			hh = 37 * hh + s[j];
		}
		hoge[hh] |= (1 << (s[0]-'a'));
	}
	cout << ans << endl;
}
