///****In the name of ALLAH, most Gracious, most Compassionate****//

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

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

typedef long long ll;
typedef pair <int, int> pii;

#define ALL(a) a.begin(), a.end()
#define FastIO ios::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define IN freopen("input.txt","r+",stdin)
#define OUT freopen("output.txt","w+",stdout)

#define DBG(a) cerr<< "line "<<__LINE__ <<" : "<< #a <<" --> "<<(a)<<endl
#define NL cout<<endl

template < class T1,class T2>
ostream &operator <<(ostream &os,const pair < T1,T2 > &p)
{
    os<<"{"<<p.first<<","<<p.second<<"}";
    return os;
}

const int N=1e6+5;



const int NUMBER_OF_HASH = 2;
struct Hash
{
    ll a[NUMBER_OF_HASH];
    Hash operator + (const ll &h ) { Hash ret ; for(int i=0;i<NUMBER_OF_HASH;i++) ret.a[i] = a[i] + h;  return ret;}
    Hash operator + (const Hash &h ) { Hash ret ; for(int i=0;i<NUMBER_OF_HASH;i++) ret.a[i] = a[i] + h.a[i];  return ret;}
    Hash operator ^ (const Hash &h ) { Hash ret ; for(int i=0;i<NUMBER_OF_HASH;i++) ret.a[i] = a[i] ^ h.a[i];  return ret;}
    Hash operator - (const Hash &h ) { Hash ret ; for(int i=0;i<NUMBER_OF_HASH;i++) ret.a[i] = a[i] - h.a[i];  return ret;}
    Hash operator * (const Hash &h ) { Hash ret ; for(int i=0;i<NUMBER_OF_HASH;i++) ret.a[i] = a[i] * h.a[i];  return ret;}
    Hash operator % (const Hash &h ) { Hash ret ; for(int i=0;i<NUMBER_OF_HASH;i++) ret.a[i] = (a[i] % h.a[i]+h.a[i])%h.a[i];  return ret;}
    bool operator== (const Hash &h ) { bool ret=1;for(int i=0;i<NUMBER_OF_HASH;i++) ret = ret and a[i] == h.a[i] ; return ret;}
    friend ostream &operator <<(ostream &os , const Hash & h)
    {
        os<<"{";
        for(int i=0;i<NUMBER_OF_HASH;i++)
            os<<","<<h.a[i];
        os<<"}";
        return os;
    }
    bool operator < (const Hash  &h) const
    {
        if(a[0]!=h.a[0])
            return a[0] < h.a[0];
        return a[1] < h.a[1];
    }

};

Hash bigmod ( Hash a, long long p, Hash m )
{
    Hash res = {1,1};
    Hash x = a;

    while ( p )
    {
        if ( p & 1 ) //p is odd
        {
            res = ( res * x ) % m;
        }
        x = ( x * x ) % m;
        p = p >> 1;
    }

    return res;
}



const Hash MOD = {(ll)1e9+7 ,(ll)1e9+9};
const Hash BASE = { (ll)(1e8 + 5e4 + 1) ,(ll) 1e9 + 87};

Hash paw[N];
Hash inv_paw[N];
Hash h[N];

void precal(int n)
{
    assert(n<=N);
    paw[0]= { 1, 1};
    for(int i=1;i<n;i++)
        paw[i] = paw[i-1] * BASE % MOD;
}
void init(const string &s)
{
    h[0] = {0,0};
    for(int i=0;i<s.size();i++)
        h[i+1]= (h[i]*BASE+s[i] ) %MOD;
}

inline Hash hashval(int l,int r) /// l,r 0 indexed
{
    return (h[r+1]-h[l]*paw[r-l+1])%MOD;
}

string s[N];
int32_t main()
{
    FastIO;


    precal(N);
    int n;
    cin>>n;
    for(int i=0;i<n;i++) cin>>s[i];
    map<Hash  , int > cnt;
    for(int i=0;i<n;i++)
    {
        init(s[i]);
        cnt[hashval(0,s[i].size()-1)]++;
    }
    ll ans = -n;
    Hash zro = { 0 , 0};
    for(int i=0;i<n;i++)
    {
        init(s[i]);
        int mask = 0;
        int m = s[i].size();
        for(int j=0;j<=m;j++)
        {
            for(int k=0;k<26;k++)
            {
                if((mask >> k)&1)
                {
                    Hash x = (hashval(j,m-1) + paw[m-j] * ( zro + ('a' + k))) % MOD;

//                    if(cnt[x])
//                    {
//                        DBG(i);
//                        DBG(j);
//
//                        DBG(s[i].substr(j));
//                        DBG(char('a' + k));
//                        DBG(cnt[x]);
//                        NL;
//                    }
                    auto it = cnt.find(x);
                    if(it!=cnt.end())
                        ans+=it->second;
                }
            }
            mask |= (1<< (s[i][j] - 'a'));
        }

    }

    cout<<ans<<"\n";
}


Measured memory_bytes: 66464