#include<bits/stdc++.h>
using namespace std;

const int nax = 1e6 + 5;
int child[nax][26]; //trie
bool isEnd[nax];
int nxt=1;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<string> in(n);
    vector<vector<int>> path(n);
    for(int i=0;i<n;i++){
        string &s=in[i];
        cin>>s;
        reverse(s.begin(),s.end());
        int node=0;
        for(char ch : s){
            path[i].push_back(node);
            if(child[node][ch-'a'] == 0) {
                child[node][ch-'a'] = nxt++;
            }
            node=child[node][ch-'a'];
        }
        isEnd[node]=true;
    }
    
    long long answer=0;
    for(int i=0;i<n;i++ ){
        string &s=in[i];
        set<char> suffix;
        for(int j=(int)s.length()-1 ;j>=0;j--){
            int node=path[i][j];
            suffix.insert(s[j]);
            for(char ch:suffix){
                answer += isEnd[child[node][ch-'a']];
            }
        }
    }
    cout<<answer - n<<endl;
    return 0;
}
