#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef vector<pll> vll;
typedef vector<vl> vvl;

#define fori(i, n) for (int i = 0; i < n; i++)
#define ford(i, n) for (int i = n - 1; i >= 0; i--)
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define repd(i, a, b) for (int i = a; i >= b; i--)
#define trav(x, a) for (auto &x : a)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define endl '\n'
#define sz(a) (int)(a).size()
#define fi first
#define se second

clock_t time_p = clock();
void time_taken()
{
    time_p = clock() - time_p;
    cerr << "Time Taken : " << (float)(time_p) / CLOCKS_PER_SEC << "\n";
}

const ll mod = 1e9 + 7;
const ll INF = 1e18;

const int maxn = 2e5 + 5;

vector<string> a(maxn);
vi b(maxn);

ll ans = 0;

#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 

void go(vi& inds,int j,vvi& suff){
    if(sz(inds) <= 1)
        return;
    vi adj[26];
    vi cnt(26);
    for (int x : inds)
    {
        fori(i,26){
            if((suff[x][j]&(1<<i)))
                cnt[i]++;
        }
    }
    // trace(inds);
    for (int x : inds)
    {
        if(b[x] == j+1){
            // trace(x, j, cnt[(a[x][j] - 'a')]);
            ans += (cnt[(a[x][j] - 'a')] - 1);
        }
        else{
            adj[(a[x][j] - 'a')].pb(x);
        }
    }
    fori(i,26){
        go(adj[i], j + 1,suff);
    }
}

int main()
{
    ios_base::sync_with_stdio(false), cin.tie(nullptr);

    int n;
    cin >> n;
    vvi suff(n);
    fori(i, n)
    {
        cin >> a[i];
        reverse(all(a[i]));
        b[i] = sz(a[i]);
        suff[i].resize(sz(a[i]));
        suff[i][b[i] - 1] = (1 << (a[i].back() - 'a'));
        ford(j, sz(a[i]) - 1)
        {
            suff[i][j] |= suff[i][j+1];
            suff[i][j] |= (1 << (a[i][j] - 'a'));
        }
    }
    vi inds(n);
    iota(all(inds), 0);
    go(inds,0,suff);
    cout << ans << endl;

    time_taken();
    return 0;
}

Measured memory_bytes: 107172