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

const int nax = 1e6 + 5;
int child[nax][26];
bitset<nax> is_end;
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>> paths(n);
    memset(child, 0, sizeof child);
    for (int i = 0; i < n; ++i) {
        auto &s = in[i];
        cin >> s;
        reverse(begin(s), end(s));
        int node = 0;
        for (char ch : s) {
            paths[i].push_back(node);
            if (child[node][ch-'a'] == 0) {
                child[node][ch-'a'] = nxt++;
            }
            node = child[node][ch-'a'];
        }
        is_end[node] = 1;
    }
    long long ans = 0;
    
    for (int i = 0; i < n; ++i) {
        auto &s = in[i];
        set<int> suffix;
        
        for (int j = (int)s.size() - 1; j >= 0; --j) {
            int node = paths[i][j];
            suffix.insert(s[j]);
            for (char ch : suffix) {
                ans += is_end[child[node][ch-'a']];
            }
        }
    }
    
    cout << ans - n;
}
