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

#define ll long long 
#define pb push_back
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define memf(a) memset(a,false,sizeof(a))
#define all(v) v.begin(),v.end()
#define sz(a) (ll)a.size()
#define F first
#define S second
#define INF 2000000000000000000
#define endl "\n"
#define _time_ 1.0 * clock() / CLOCKS_PER_SEC
#define popcount(x) __builtin_popcountll(x)
#define pll pair<ll,ll> 
#define ld long double

const int M=1000000007;
const int MM=998244353;
const long double PI = acos(-1);

ll power(ll b,ll e,ll m)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b%m,e/2,m)%m;
	return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b,e/2);
	return power(b*b,e/2);
}
#define int long long
template<typename T, typename U> static inline void amin(T &x, U y){ if(y<x) x=y; }
template<typename T, typename U> static inline void amax(T &x, U y){ if(x<y) x=y; }
template<typename T, typename U> ostream& operator<<(ostream &os, const pair<T, U> &p)
{ 
    return os<<'('<<p.F<< ","<<p.S<<')'; 
}

const int ALPHABET_SIZE = 26; 
  
// trie node 
struct TrieNode 
{ 
    struct TrieNode *children[ALPHABET_SIZE]; 
  	int cnt[ALPHABET_SIZE];
    // isEndOfWord is true if the node represents 
    // end of a word 
    int isEndOfWord=0; 
    int count=0;
}; 
  
// Returns new trie node (initialized to NULLs) 
struct TrieNode *getNode(void) 
{ 
    struct TrieNode *pNode =  new TrieNode; 
  
    pNode->isEndOfWord = 0; 	
    for (int i = 0; i < ALPHABET_SIZE; i++) 
        pNode->children[i] = NULL,pNode->cnt[i]=0; 
  
    return pNode; 
} 
  
// If not present, inserts key into trie 
// If the key is prefix of trie node, just 
// marks leaf node 
void insert(struct TrieNode *root, string key) 
{ 
    struct TrieNode *pCrawl = root; 
  
    for (int i = 0; i < key.length(); i++) 
    { 
        int index = key[i] - 'a'; 
        if (!pCrawl->children[index]) 
            pCrawl->children[index] = getNode(); 
  
        pCrawl = pCrawl->children[index]; 
    } 
  
    // mark last node as leaf 
    pCrawl->isEndOfWord += 1; 
} 
using node = TrieNode;
void dfs(node* r)
{
	assert(r!=NULL);
	r->count=r->isEndOfWord;
	for(int i=0;i<26;++i)
	{
		if(r->children[i])
		{
			dfs(r->children[i]);
			r->count += r->children[i]->count;
			//for(int j=0;j<26;++j)
			//	r->cnt[j]+=r->children[i]->cnt[j];
		}
	}
	for(int j=0;j<26;++j)
	{
		if(r->children[j])
			r->cnt[j]+=r->children[j]->count;
		for(int k=0;k<26;++k)
		{
			if(j==k)continue;
			if(r->children[k])
					r->cnt[j]+=r->children[k]->cnt[j];
		}
	}
}

ll go_(node* root,string &s)
{
	char c=s.back();
	s.pop_back();
	int n=sz(s);
	node *temp=root;
	for(int i=0;i<n;++i)
	{
		int x = s[i]-'a';
		temp = temp->children[x];
	}
	return temp->cnt[c-'a'];
}

int _runtimeTerror_()
{
	TrieNode *r=getNode();
	int n;
	cin>>n;
	vector<string> v(n);
	for(int i=0;i<n;++i)
	{
		cin>>v[i];
		reverse(all(v[i]));
		//cout<<v[i]<<"\n";
		insert(r,v[i]);
	}
	dfs(r);
	ll ans=0;
	for(int i=0;i<n;++i)
	{
		ans+=go_(r,v[i])-1;
		//cout<<ans<<"\n";
	}
	cout<<ans<<"\n";
	return 0;
}

signed main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#ifdef runSieve
		sieve();
	#endif
	#ifdef NCR
		initialize();
	#endif
	int TESTS=1;
	//cin>>TESTS;
	while(TESTS--)
		_runtimeTerror_();
	return 0;
}

Measured memory_bytes: 466796