#include <bits/stdc++.h>
using namespace std;
						
#define fast_cin() ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define endl '\n'
#define int long long

const int A = 26;

struct node {
	bool word = false;
	node* child[A];
	node() {
		for (int i = 0; i < A; ++i) {
			child[i] = NULL;
		}
	}
};
				
int32_t main() {
	fast_cin();  
	int n; cin >> n;
	vector<string> v(n);
	for (string &s : v) {
		cin >> s;
	}
	sort(v.begin(), v.end(), [&](string &a, string &b) {
		return (int)a.size() < (int)b.size();
	});
	node *root = new node;
	int ans = 0;
	for (string &s : v) {
		int n = s.size();
		int cnt[A] = {0};
		for (char &c : s) ++cnt[c - 'a'];
		node *cur = root;
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < A; ++j) {
				if (cnt[j] and cur->child[j] != NULL and (cur->child[j])->word == true) {
					++ans;
				}
			}
			int now = s[n - i - 1] - 'a';
			--cnt[now];
			if (cur->child[now] == NULL) {
				cur->child[now] = new node;
			}
			cur = cur->child[now];
		}
		cur->word = true;
	}
	cout << ans << endl;
	return 0;
}