#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <ll, ll> pii;
typedef pair <ll, pii> ipi;
#define fi first
#define se second
#define pb push_back
const int MOD = 1e9 + 7;
const int MAX = 2e5 + 5;
const int dx[4] = {0, 0, 1, -1};
const int dy[4] = {1, -1, 0, 0};
#define int ll
bool check(string s, string t){
int n = (int)s.size();
int m = (int)t.size();
for(int i = 0 ; i + m - 1 < n ; i++){
if(t == s.substr(i, m))return 1;
}
return 0;
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int n; cin >> n;
string s[n + 5];
for(int i = 1 ; i <= n ; i++)cin >> s[i];
int ans = 0;
for(int i = 1 ; i <= n ; i++){
for(int j = 1 ; j <= n ; j++){
if(i == j)continue;
ans += check(s[i], s[j]);
}
}
cout << ans << endl;
return 0;
}