// Online C++ compiler to run C++ program online
#include <bits/stdc++.h>
using namespace std;
bool custom(string s, string t){
if(s.size()==t.size()) return s<t;
return s.size()<t.size();
}
int checkBranch(vector<vector<int>>& adj, vector<string>& names, int parent, int node, int depth){
if(names[parent]==names[node]) depth++;
int sdepth = depth;
for(int v : adj[parent]){
if(names[v].size()<names[node].size()) continue;
int pos = 0;
for(char c : names[v]){
if(c==names[node][pos]){
pos++;
if(pos==names[node].size()){
depth = checkBranch(adj, names, v, node, depth+1);
break;
}
}else pos=0;
}
}
if(sdepth==depth) adj[parent].push_back(node);
return depth;
}
int main() {
int n;
cin>>n;
vector<string> names(n);
for(int i=0;i<n;i++) cin>>names[i];
sort(names.rbegin(),names.rend(),custom);
int total = 0;
for(int i=0;i<n;i++){
for(int j=i+1;j<n;j++){
int b=0;
if(names[i]==names[j]) total++;
for(char c : names[i]){
//cout<<c<<" "<<names[j][b]<<endl;
if(c==names[j][b]) b++;
else b=0;
if(b==names[j].size()) break;
}
if(b==names[j].size()) total++;
//cout<<names[j]<<" "<<names[i]<<" "<<total<<endl;
}
}
cout<<total<<endl;
return 0;
}