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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

class Prints {
private:
    class __Prints {
    public:
        __Prints(const char* sep, const char* term) : sep(sep), term(term) {}
        template <class... Args>
        void operator()(Args&&... args) const { print(std::forward<Args>(args)...); }

    private:
        const char *sep, *term;
        void print() const { std::cout << term; }
        void print_rest() const { std::cout << term; }
        template <class T, class... Tail>
        void print(T&& head, Tail&&... tail) const { std::cout << head, print_rest(std::forward<Tail>(tail)...); }
        template <class T, class... Tail>
        void print_rest(T&& head, Tail&&... tail) const { std::cout << sep << head, print_rest(std::forward<Tail>(tail)...); }
    };

public:
    Prints() {}
    __Prints operator()(const char* sep = " ", const char* term = "\n") const { return __Prints(sep, term); }
    template <class T>
    void print_vec(const std::vector<T>& vec, const char* sep = " ", const char* term = "\n") const {
        const size_t sz = vec.size();
        for (size_t i = 0; i < sz; i++) std::cout << vec[i] << (i == sz - 1 ? term : sep);
    }
};

Prints prints;

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

template <int char_num, char base>
class Trie {
private:
    struct Node {
        std::array<int, char_num> children;
        std::vector<int> accept;
        std::array<int, char_num> count;
        int common = 0;
        int c;
        Node(int c) : c(c) {
            children.fill(-1);
            count.fill(0);
        }
    };

    std::vector<Node> nodes;
    const int root = 0;

public:
    Trie() {
        nodes.emplace_back(root);
    }
    void add(const string& str, int str_id) {
        int node_id = 0;
        int sz = static_cast<int>(str.size());
        for (int i = 0; i < sz; i++) {
            int c = static_cast<int>(str[i] - base);
            int next_id = nodes[node_id].children[c];
            if (next_id == -1) {
                next_id = static_cast<int>(nodes.size());
                nodes[node_id].children[c] = next_id;
                nodes.push_back(Node(c));
            }
            ++nodes[node_id].common;
            node_id = next_id;
        }
        ++nodes[node_id].common;
        nodes[node_id].accept.emplace_back(str_id);
    }
    void add(const string& str) {
        add(str, nodes[0].common);
    }
    int query(const string& str, char x) {
        int node_id = 0;
        int sz = static_cast<int>(str.size());
        for (int i = 0; i < sz; i++) {
            int c = static_cast<int>(str[i] - base);
            int next_id = nodes[node_id].children[c];
            if (next_id == -1) {
                return 0;
            }
            node_id = next_id;
        }
        return nodes[node_id].count[x - base];
    }
    int count() {
        return nodes[0].common;
    }
    int size() {
        return static_cast<int>(nodes.size());
    }

    void dfs(int idx) {
        auto& count = nodes[idx].count;
        for (int i = 0; i < char_num; i++) {
            int u = nodes[idx].children[i];
            if (u == -1) continue;
            dfs(u);
            count[i] += nodes[u].common;
            for (int j = 0; j < char_num; j++) {
                if (j == i) continue;
                count[j] += nodes[u].count[j];
            }
        }
    }
};

void solve() {
    ll N;
    cin >> N;
    vector<string> S(N);
    Trie<26, 'a'> trie;
    for (ll i = 0; i < N; i++) {
        cin >> S[i];
        reverse(S[i].begin(), S[i].end());
        trie.add(S[i]);
    }
    trie.dfs(0);
    ll ans = 0;
    for (ll i = 0; i < N; i++) {
        ans += trie.query(S[i].substr(0, (int)S[i].size() - 1), S[i].back()) - 1;
    }
    prints()(ans);
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    cout << setprecision(18) << fixed;
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 283256