#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <limits>
#include <list>
#include <numeric>
#include <queue>
#include <stack>
#include <utility>
#include <array>
#include <random>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <assert.h>
using namespace std;
typedef long long ll;
#define dump(x) cerr << #x << " = " << (x) << " [" << __LINE__ << ":" << __FUNCTION__ << "] " << endl;
// vector出力
template < typename T >
ostream& operator<<(ostream& os, vector< T >& v) {
    os << "{";
    for (int i = 0; i < (int)v.size(); i++) {
        os << v[i] << (i < v.size() - 1 ? ", " : "");
    }
    os << "}";
    return os;
}
// pair出力
template < typename T, typename U >
ostream& operator<<(ostream& os, pair< T, U >& p) {
    return os << "(" << p.first << ", " << p.second << ")";
}
// map出力
template < typename T, typename U >
ostream& operator<<(ostream& os, map< T, U >& map_var) {
    os << "{";
    for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
        os << "(" << itr->first << ", " << itr->second << ")";
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set 出力
template < typename T >
ostream& operator<<(ostream& os, set< T >& set_var) {
    os << "{";
    for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
        os << *itr;
        ++itr;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
#pragma endregion

/////////////////////////////////////////

int n;
vector< vector< int > > g;
vector< bool > is_end;
vector<string> s;

int dfs(int m, ll &f, int t = 0, int node = 0) {
    if (t == s[m].size()) {
        f = 0;
        return 0;
    }
    else if (t == s[m].size() - 1) {
        dfs(m,f,t+1,g[node][s[m][t]-'a']);
        f |= 1<<(s[m][t]-'a');
        return 0;
    }
    else {
        int ret = 0;
        ret += dfs(m,f,t+1,g[node][s[m][t]-'a']);
        f |= 1<<(s[m][t]-'a');
        for(int i = 0;i < 26;i++) {
            if (g[node][i] == 0) continue;
            if (is_end[g[node][i]] && (f & (1 << i))) {
                ret++;
            }
        }
        return ret;
    }
}

int main() {
    cin >> n;
    s.resize(n);
    g.resize(1, vector< int >(26, 0)); // 木 (最初はrootのみ)
    is_end.resize(1,false); // 末尾か
    for (int i = 0; i < n; i++) {
        cin >> s[i];
        reverse(s[i].begin(), s[i].end());
        int node = 0;
        int t = 0;
        while (t < s[i].size()) {
            // ノードがないなら追加
            if (g[node][s[i][t] - 'a'] == 0) {
                g[node][s[i][t] - 'a'] = (int)g.size();
                g.push_back(vector< int >(26, 0));
                is_end.push_back(false);
            }
            node = g[node][s[i][t] - 'a'];
            t++;
        }
        is_end[node] = true;
    }
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        ll f;
        ans += dfs(i,f);
    }
    cout << ans << endl;
    return 0;
}

/////////////////////////////////////////

Measured memory_bytes: 181072