/*

Code for problem B by cookiedoth
Generated 09 Aug 2020 at 03.11 PM


СТРОИМ СТЕНУ РАБОТЯГИ!
█▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀█
█═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═█
█═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═█
█═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═█
█═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═█
█═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═█
█═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═█
█═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═█
█═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═╩═╦═█
█▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄█

^_^
-_-
z_z

*/

#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <functional>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <complex>
#include <cassert>
#include <random>
#include <cstring>
#include <numeric>
#define ll long long
#define ld long double
#define null NULL
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define debug(a) cerr << #a << " = " << a << endl
#define forn(i, n) for (int i = 0; i < n; ++i)
#define sz(a) (int)a.size()

using namespace std;

template<class T> int chkmax(T &a, T b) {
	if (b > a) {
		a = b;
		return 1;
	}
	return 0;
}

template<class T> int chkmin(T &a, T b) {
	if (b < a) {
		a = b;
		return 1;
	}
	return 0;
}

template<class iterator> void output(iterator begin, iterator end, ostream& out = cerr) {
	while (begin != end) {
		out << (*begin) << " ";
		begin++;
	}
	out << endl;
}

template<class T> void output(T x, ostream& out = cerr) {
	output(x.begin(), x.end(), out);
}

void fast_io() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

const int mx = 1e6 + 228;
const int K = 26;
int n, ptr, go[mx][K], dp[mx][K], subtreeSz[mx], term[mx];

int add_vertex() {
	for (int i = 0; i < K; ++i) {
		go[ptr][i] = -1;
	}
	return ptr++;
}

void add_string(string s) {
	// cerr << "add_string " << s << endl;
	int v = 0;
	for (auto c : s) {
		int id = c - 'a';
		if (go[v][id] == -1) {
			go[v][id] = add_vertex();
		}
		v = go[v][id];
	}
	term[v]++;
}

void calc_dp(int v) {
	for (int i = 0; i < K; ++i) {
		int v1 = go[v][i];
		if (v1 != -1) {
			// cerr << "edge " << v << " " << v1 << " " << (char)('a' + i) << endl;
			calc_dp(v1);
			for (int j = 0; j < K; ++j) {
				if (j == i) {
					dp[v][j] += subtreeSz[v1];
				} else {
					dp[v][j] += dp[v1][j];
				}
			}
			subtreeSz[v] += subtreeSz[v1];
		}
	}
	subtreeSz[v] += term[v];
	// cerr << v << " " << subtreeSz[v] << " " << dp[v][0] << " " << dp[v][2] << endl;
}

ll ans;

void add_to_ans(string s, int last_c) {
	int v = 0;
	for (auto c : s) {
		int id = c - 'a';
		if (go[v][id] == -1) {
			assert(0);
			go[v][id] = add_vertex();
		}
		v = go[v][id];
	}
	ans += (ll)(dp[v][last_c] - 1);
}

vector<string> s;

void init() {
	add_vertex();
}

void read() {
	cin >> n;
	s.resize(n);
	for (int i = 0; i < n; ++i) {
		cin >> s[i];
	}
}

void build_trie() {
	for (int i = 0; i < n; ++i) {
		reverse(all(s[i]));
		add_string(s[i]);
	}
	calc_dp(0);
}

void calc_ans() {
	for (int i = 0; i < n; ++i) {
		int last_c = s[i].back() - 'a';
		s[i].pop_back();
		add_to_ans(s[i], last_c);
	}
}

signed main() {
	fast_io();
	init();
	read();
	build_trie();
	calc_ans();
	cout << ans << '\n';
}


Measured memory_bytes: 285552