#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>

using namespace std;

const int MaxN = 5005;
const int MaxL = 505;

struct Elem {
    string str;
    int idx;
    int rev;

    bool operator<(const Elem& other) const {
        return str < other.str;
    }
} elem[2 * MaxN];

int n;
string str[MaxN];

int first[MaxN][2 * MaxL];
int last[MaxN][2 * MaxL];
int t[2 * MaxL];

bool isPalin[MaxN];

int sum[2 * MaxN][2 * MaxL];

int calc(int a, int b, int c) {
    int ret = sum[b][c];
    if (a > 0) ret -= sum[a - 1][c];
    return ret;
}

int tadd = 0;

bool palin(string str) {
    int to = str.size() / 2;
    for (int i = 0; i < to; ++i)
        if (str[i] != str[str.size() - i - 1])
            return false;
    return true;
}

int main() {
    freopen("palap.in", "r", stdin);
    freopen("palap.out", "w", stdout);
    memset(isPalin, 0, sizeof(isPalin));
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        char tmp[505];
        scanf("%s", &tmp);
        str[i] = string(tmp);
        if (palin(str[i])) {
            ++tadd;
            isPalin[i] = true;
        }
    }
    memset(first, 0, sizeof(first));
    memset(last, 0, sizeof(last));
    for (int i = 0; i < n; ++i) {
        memset(t, 0, sizeof(t));
        string s = "";
        for (int j = 0; j < str[i].size(); ++j) {
            s += str[i][j];
            if (j != n - 1) s += '#';
        }
        int sz = s.size();
        int l = 0, r = 0;
        for (int j = 0; j < sz; ++j) {
            int k;
            if (j >= r) k = 0;
            else k = min(t[r - j + 1], r - j);
            while (j - k >= 0 && j + k < sz && s[j - k] == s[j + k]) ++k;
            t[j] = k - 1;
            if (j + t[j] > r) {
                l = j - t[j];
                r = j + t[j];
            }
        }
        for (int j = 0; j < sz; ++j) {
            if (j - t[j] == 0) {
                first[i][j + t[j]] = 1;
            }
            if (j + t[j] == sz - 1) {
                last[i][j - t[j]] = 1;
            }
        }
    }
    for (int i = 0; i < n; ++i) {
        elem[i].str = str[i];
        elem[i].idx = i;
        elem[i].rev = 0;
        string rev = "";
        int sz = str[i].size();
        for (int j = 0; j < sz; ++j)
            rev += str[i][sz - j - 1];
        elem[n + i].str = rev;
        elem[n + i].idx = i;
        elem[n + i].rev = 1;
    }
    sort(elem, elem + 2 * n);
    memset(sum, 0, sizeof(sum));
    for (int i = 0; i < 2 * n; ++i) {
        if (elem[i].rev == 0) {
            int sz = elem[i].str.size();
            for (int j = 0; j < sz; ++j) {
                if (last[elem[i].idx][j]) sum[i][j] = 1;
            }
        } else {
            int sz = elem[i].str.size();
            for (int j = 0; j < sz; ++j) {
                if (first[elem[i].idx][sz - j - 1]) sum[i][j] = 1;
            }
        }
        sum[i][elem[i].str.size()] = 1;
    }
    for (int j = 0; j < 2 * MaxL; ++j) {
        for (int i = 1; i < 2 * n; ++i)
            sum[i][j] += sum[i - 1][j];
    }
    int res = 0;
    int res2 = 0;
    for (int i = 0; i < 2 * n; ++i) {
        int low = i;
        int high = 2 * n - 1;
        while (low < high) {
            int mid = (low + high + 1) / 2;
            int k = 0;
            int sz1 = elem[i].str.size();
            int sz2 = elem[mid].str.size();
            while (k < sz1 && k < sz2 && elem[i].str[k] == elem[mid].str[k]) ++k;
            if (k == sz1) low = mid;
            else high = mid - 1;
        }
        int tmp = 0;
        if (low > i) tmp = calc(i + 1, low, elem[i].str.size());
        if (isPalin[elem[i].idx]) res2 += tmp;
        else res += tmp;
    }
    res2 += tadd;
    printf("%d\n", res + res2 / 2);
    return 0;
}
