#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
vector<string> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
auto is = [&](string x, string y) {
int n = x.size(), m = y.size();
if (n > m) return false;
for (int i = 0; i + n <= m; i++) {
if (y.substr(i, n) == x) {
return true;
}
}
return false;
};
int ans = 0;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (j == i) continue;
ans += is(a[i], a[j]);
}
}
cout << ans << '\n';
return 0;
}