#include<iostream>
#include<fstream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<deque>
#include<set>
#include<map>
#include<bitset>
#include<ctime>
#include<queue>
using namespace std;
#define int long long
#define pii pair <int, int>
#define XX first
#define YY second

// constants:
const int mn = 200005;
const int mod = 1000000007;
const long long inf = 4444444444444444444;
const int sminf = 1111111111;
const bool is_multitest = 0;
const bool is_interactive = 0;

// i/o methods:
const bool input_from_file = 0;
const bool output_to_file = 0;
#define filename ""
#define in_extension "inp"
#define out_extension "out"

// data preprocessing: (e.g.: divisor generating, prime sieve)
void preprocess()
{
    
}

// global variables:
int n;
string s[mn];

class prefix_tree {
private:
    struct node {
        int child[26];
        int is_word;
        int count_words;
        char letter;
        node() {
            for (int i=0; i<26; i++) child[i] = -1;
            is_word = count_words = 0;
            letter = '0';
        }
    } nil;

    vector <node> nodes;
public:
    void add_word(string s) {
        int ptr = 0;
        for (char c:s) {
            nodes[ptr].count_words++;
            int p2 = nodes[ptr].child[c-'a'];
            if (p2==-1) {
                p2 = nodes[ptr].child[c-'a'] = nodes.size();
                nodes.push_back(nil);
                nodes[p2].letter = c;
            }
            ptr = p2;
        }
        nodes[ptr].count_words++;
        nodes[ptr].is_word ++;
        // for (node i:nodes) cout<<i.count_words<<" "<<i.is_word<<" "<<i.letter<<"\n";
        // cout<<"\n";
    }

    int index_of_string(string s) {
        int ptr = 0;
        for (char c:s) {
            int p2 = nodes[ptr].child[c-'a'];
            if (p2 == -1) return -1;
            ptr = p2;
        }
        return ptr;
    }

    vector <int> dpret[26]; // dp[c][i] -  number of words pass node i, has letter c in the back
    bool initialized;
    int dp(char c, int i) {
        if (!initialized) {
            initialized = 1;
            for (int i=0; i<26; i++) dpret[i].assign(nodes.size(), -1);
        }
        if (dpret[c-'a'][i] != -1) return dpret[c-'a'][i];
        if (c==nodes[i].letter) return dpret[c-'a'][i] = nodes[i].count_words;
        int ret = 0;
        for (int j=0; j<26; j++) if (nodes[i].child[j] != -1) {
            ret += dp(c, nodes[i].child[j]);
        }
        return dpret[c-'a'][i] = ret;
    }

    int find_ans(char c, int i) {
        int ret = 0;
        for (int j=0; j<26; j++) if (nodes[i].child[j] != -1) {
            ret += dp(c, nodes[i].child[j]);
        }
        return ret;
    }

    prefix_tree() {
        initialized = 0;
        nodes = {nil};
    }
} ptree;
// main solution goes here:
void execute(int test_number)
{
    cin>>n;
    for (int i=1; i<=n; i++) {
        cin>>s[i];
        reverse(s[i].begin(), s[i].end());
        ptree.add_word(s[i]);
    }

    int ans = 0;
    for (int i=1; i<=n; i++) {
        ans += ptree.find_ans(s[i].back(), ptree.index_of_string(s[i].substr(0, s[i].size()-1)));
    }
    cout<<ans-n;
}
// REMEMBER TO CHOOSE TEST METHODS
// PLEASE REMOVE cout AND cerr DEBUG LINES BEFORE SUBMITTING PROBLEMS
// Solution by low_



















signed main()
{
#ifdef lowie
    if (!is_interactive)
    {
        freopen("test.inp", "r", stdin);
        freopen("test.out", "w", stdout);
    }
#else
    if (input_from_file) freopen(filename"."in_extension, "r", stdin);
    if (output_to_file) freopen(filename"."out_extension, "w", stdout);
#endif
    if (!is_interactive)
    {
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
    }

    preprocess();
    int ntest;
    if (is_multitest) cin >> ntest;
    else ntest = 1;

    for (int testno = 1; testno <= ntest; testno++)
    // use for instead of while to serve facebook hacker cup test format
    {
        execute(testno); // only start coding in this function, not in main
    }
}
// Template by low_
// Contact me via mail: ttuandung1803@gmail.com
// ...or codeforces: www.codeforces.com/profiles/low_
// ...or if you're interested in food: www.instagram.com/lowie.exe/

Measured memory_bytes: 511632