#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<deque>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'009; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

const int NUM_a = 26;

//https://teratail.com/questions/207411?sip=n0070000_019&uid=99331
 
template <class T, size_t Dim>
class multi_vector : public std::vector<multi_vector<T, Dim-1>>
{
public:
	multi_vector()
	{
	}
	
	template <typename N, typename... Sizes>
	multi_vector(T i, N n, Sizes... sizes) : std::vector<multi_vector<T, Dim-1>>(n, multi_vector<T, Dim-1>(i, sizes...))
	{
	}
	 
	template <typename N, typename... Sizes>
	void resize(T i, N n, Sizes... sizes) 
	{
		std::vector<multi_vector<T, Dim-1>>::resize(n,multi_vector<T, Dim-1>(i, sizes...));
	}
};
 
template <class T>
class multi_vector<T, 1> : public std::vector<T>
{
public:
	
	multi_vector()
	{
	}
	
	template <typename N>
	multi_vector(T i, N n) : std::vector<T>(n, i)
	{
	}
	
	template <typename N>
	void resize(T i, N n)
	{
		std::vector<T>::resize(n, i);
	}
	
};

constexpr char C = 'a';

struct trie{
	
	trie *child[NUM_a];
	int val;
	
	trie() {
		val = 0;
		// for(int _ = 0; _ < NUM_a; _++) child[_] = NULL;
		fill(child,child + NUM_a, (trie *)(0));
	}
	
	~trie() {
		/**
		*
		*
		**/
	}
	
	void add(char *c){
		if(*c == '\0') return;
		if(this->child[*c-C] == NULL){
			trie *node = new trie();
			this->child[*c-C] = node;
		}
        
        if(*(c+1) == '\0') this->child[*c-C]->val++;
        
		this->child[*c-C]->add(c+1);
	}
	
	int find(char *c){
		if(*c == '\0'){
			int con = 0;
			for(int _ = 0; _ < NUM_a; _++){
				if(this->child[_] != NULL) con += this->child[_]->val;
			}
			return this->val - con;
		}
		
		if(this->child[*c-C] == NULL) return 0;
		else  return this->child[*c-C]->find(c+1);
	}
	
	void del(char *c){
		if(*c == '\0') return ;
		
		if(this->child[*c-C] != NULL){
			this->child[*c-C]->del(c+1);
			if(child[*c-C]->val == 1) {
				delete child[*c-C];
				child[*c-C] = NULL;
			} else child[*c-C]->val--;
		}
	}
	
	void print(int depth = 0){
		for(int _ = 0; _ < NUM_a; _++){
			if(child[_] != NULL){
				for(int __ = 0; __ < depth; __++) cout<<" ";
				cout<<(char)(C+_)<<" "<<child[_]->val<<endl;
				this->child[_]->print(depth+1);
			}
		}
	}
    
    int count(char *c, vector<bool> &con, int num, int si, bool flag){
		if(*c == '\0'){
			return 0;
		}
        
        int sum = 0;
        
		if(this->child[*c-C] != NULL)  sum += this->child[*c-C]->count(c+1, con, num-1, si, true);
        else count(c+1, con, num-1, si, false);
        
        con[*c - C] = true;
        
        if(flag) {
             for(int _ = 0; _ < NUM_a; _++){
                trie *t = this->child[_];
                
                if(t == NULL) continue;
                
                if(con[_]) {
                    sum += t->val;
                }
                
            }
        }
        
        return sum;
	}
};

signed main(){
	cout<<fixed<<setprecision(10);
	
	int N;
	vector<string> S;
    trie tr;
	int count = 0;
	
	cin>>N;
	
	S.resize(N);
	
	for(int i = 0; i < N; i++){
		cin>>S[i];
	}
	
	sort(S.begin(), S.end(), [](string const& lhs, string const& rhs) {
		return lhs.size() < rhs.size();
	});
    
	
    
	for(int i = 0; i < N; i++){
		vector<bool> con(NUM_a, false);
        
        reverse(S[i].begin(), S[i].end());
        
        count += tr.count(&S[i][0], con, S[i].size()-1, S[i].size(), true);
        
        tr.add(&S[i][0]);
        
        S[i].clear();
	}
    
    cout<<count<<endl;
	
	return 0;
}

Measured memory_bytes: 265360