#include <bits/stdc++.h>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,Q,K,A,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
typedef pair<ll, ll> P;
const ll INF = (1LL<<58);
template <long long mod> class mint{
    public:
        ll x;
        long long mod_plus;
        mint(){x = 0;}
        mint(ll _x){
            mod_plus = (LLONG_MAX / mod) * mod;
            x = (_x < 0 ? ((_x += mod_plus) < 0 ? _x + mod_plus : _x) : _x)%mod;
        }

        mint operator-(){
            return x == 0 ? 0 : mod - x;
        }
        mint& operator+=(const mint& a){
            if((x += a.x) >= mod) x -= mod;
            return *this;
        }
        mint operator+(const mint& a) const{
            return (*this) += a;
        }
        mint& operator-=(const mint& a){
            if((x -= a.x) < 0) x += mod;
            return *this;
        }
        mint operator-(const mint& a) const{
            return (*this) -= a;
        }
        mint& operator*=(const mint& a){
            (x *= a.x)%=mod;
            return *this;
        }
        mint operator*(const mint& a) const{
            return (*this) *= a;
        }
        mint pow(unsigned long long pw) const{
            mint res(1), comp(*this);
            while(pw){
                if(pw&1) res *= comp;
                comp *= comp;
                pw >>= 1;
            }
            return res;
        }
        //以下、modが素数のときのみ
        mint inv() const{
            mint res(*this);
            return res.pow(mod - 2);
        }
        mint& operator/=(const mint &a){
            (x *= a.inv().x)%=mod;
            return *this;
        }
        mint operator/(const mint &a) const{
            return (*this) /= a;
        }
};

using mint1 = mint<998244353>;
using mint2 = mint<1000000007>;
using mint3 = mint<1000000009>;
using mykey = tuple<int, int, ll, ll, ll>;

int main(){
    set<mykey> hash_num;
    cin>>N;
    vector<string> s(N);
    vector<vector<mint1> > memo1(N, vector<mint1>(1, mint1(0)));
    vector<vector<mint2> > memo2(N, vector<mint2>(1, mint2(0)));
    vector<vector<mint3> > memo3(N, vector<mint3>(1, mint3(0)));
    rep(i,N){
        cin>>s[i];
        reverse(ALL(s[i]));
        mint1 a1(0);
        mint2 a2(0);
        mint3 a3(0);
        rep(j, s[i].size() - 1){
            (a1 *= 26) += s[i][j] - 'a';
            (a2 *= 26) += s[i][j] - 'a';
            (a3 *= 26) += s[i][j] - 'a';
            memo1[i].push_back(a1);
            memo2[i].push_back(a2);
            memo3[i].push_back(a3);
        }
        mykey now_key = make_tuple(*s[i].rbegin() - 'a', s[i].size() - 1, a1.x, a2.x, a3.x);
        hash_num.insert(now_key);
    }
    ll res = 0;
    rep(i,N){
        vector<bool> exist(26, false);
        Rrep(j, s[i].size()){
            exist[s[i][j] - 'a'] = true;
            rep(k, 26){
                if(exist[k] && hash_num.find(make_tuple(k, j, memo1[i][j].x, memo2[i][j].x, memo3[i][j].x)) != hash_num.end()){
                    ++res;
                }
            }
        }
    }
    cout<<res - N<<endl;
}


Measured memory_bytes: 109228