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

typedef long long ll;
typedef pair <int , int> pii;
typedef long double ld;

const int N = 1e6+10 , mod = 1e9+7 , M = 26;

int nxt[N][M] , cnt[N][M] , id = 1;

int32_t main(){
   ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
   int n;
   cin >> n;
   string s[n];
   for(int i = 0 ; i < n ; i++){
      cin >> s[i];
      int m = s[i].length();
      int cur = 0;
      for(int j = m - 1 ; j > 0 ; j--){
         if(!nxt[cur][s[i][j] - 'a']){
            nxt[cur][s[i][j] - 'a'] = id++;
         }
         cur = nxt[cur][s[i][j] - 'a'];
      }
      cnt[cur][s[i][0] - 'a']++;
   }
   ll ans = 0;
   for(int i = 0 ; i < n ; i++){
      int m = s[i].length();
      int cur = 0;
      int num[26];
      memset(num , 0 , sizeof(num));
      for(int j = 0 ; j < m ; j++)
         num[s[i][j] - 'a']++;
      for(int j = m - 1 ; j >= 0 ; j--){
         for(int k = 0 ; k < 26 ; k++){
            if(num[k])
               ans += cnt[cur][k];
         }
         cur = nxt[cur][s[i][j] - 'a'];
         num[s[i][j] - 'a']--;
      }
   }
   ans -= n;
   cout << ans;
   return 0;
}
