#include <bits/stdc++.h>
using namespace std;
const long long BASE1 = 987654321;
const long long BASE2 = 123456789;
const long long MOD = 998244353;
vector<long long> power, inv;
vector<long long> power2, inv2;
long long modpow(long long a, long long b){
  long long ans = 1;
  while (b > 0){
    if (b % 2 == 1){
      ans *= a;
      ans %= MOD;
    }
    a *= a;
    a %= MOD;
    b /= 2;
  }
  return ans;
}
long long modinv(long long a){
  return modpow(a, MOD - 2);
}
void precalc(int n){
  power = vector<long long>(n);
  power[0] = 1;
  for (int i = 1; i < n; i++){
    power[i] = power[i - 1] * BASE1 % MOD;
  }
  inv = vector<long long>(n);
  inv[0] = 1;
  inv[1] = modinv(BASE1);
  for (int i = 2; i < n; i++){
    inv[i] = inv[i - 1] * inv[1] % MOD;
  }
  power2 = vector<long long>(n);
  power2[0] = 1;
  for (int i = 1; i < n; i++){
    power2[i] = power2[i - 1] * BASE2 % MOD;
  }
  inv2 = vector<long long>(n);
  inv2[0] = 1;
  inv2[1] = modinv(BASE2);
  for (int i = 2; i < n; i++){
    inv2[i] = inv2[i - 1] * inv2[1] % MOD;
  }
}
struct rolling_hash{
  int N;
  vector<long long> S1;
  vector<long long> S2;
  rolling_hash(){
  }
  rolling_hash(string s){
    N = s.size();
    S1 = vector<long long>(N + 1, 0);
    for (int i = 0; i < N; i++){
      S1[i + 1] = (S1[i] + s[i] * power[i]) % MOD;
    }
    S2 = vector<long long>(N + 1, 0);
    for (int i = 0; i < N; i++){
      S2[i + 1] = (S2[i] + s[i] * power2[i]) % MOD;
    }
  }
  int size(){
    return N;
  }
  pair<long long, long long> hash(int L, int R){
    long long ans1 = (S1[R] - S1[L] + MOD) * inv[L] % MOD;
    long long ans2 = (S2[R] - S2[L] + MOD) * inv2[L] % MOD;
    return make_pair(ans1, ans2);
  }
  pair<long long, long long> all(){
    return make_pair(S1[N], S2[N]);
  }
};
pair<pair<long long, long long>, int> merge(pair<pair<long long, long long>, int> A, pair<pair<long long, long long>, int> B){
  long long ans1 = (A.first.first + B.first.first * power[A.second]) % MOD;
  long long ans2 = (A.first.second + B.first.second * power2[A.second]) % MOD;
  int ans3 = A.second + B.second;
  return make_pair(make_pair(ans1, ans2), ans3);
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  precalc(1000001);
  int N;
  cin >> N;
  vector<string> S(N);
  for (int i = 0; i < N; i++){
    cin >> S[i];
  }
  vector<rolling_hash> RH(N);
  for (int i = 0; i < N; i++){
    RH[i] = rolling_hash(S[i]);
  }
  vector<map<pair<long long, long long>, int>> mp(1000001);
  for (int i = 0; i < N; i++){
    mp[S[i].size()][RH[i].all()]++;
  }
  long long ans = 0;
  for (int i = 0; i < N; i++){
    int sz = S[i].size();
    if (sz == 1){
      continue;
    }
    vector<bool> alphabet(26, false);
    for (int j = 1; j <= sz; j++){
      if (j > 0){
        alphabet[S[i][j - 1] - 'a'] = true;
      }
      if (j == 1){
        continue;
      }
      for (int k = 0; k < 26; k++){
        if (alphabet[k]){
          pair<pair<long long, long long>, int> A = make_pair(make_pair((int)('a' + k), (int)('a' + k)), 1);
          pair<pair<long long, long long>, int> B = make_pair(RH[i].hash(j, sz), sz - j);
          pair<pair<long long, long long>, int> C = merge(A, B);
          if (mp[sz - j + 1].count(C.first)){
            ans += mp[sz - j + 1][C.first];
          }
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 133524