#include <bits/stdc++.h>

using namespace std;

const int N = 1e6 + 5;
const int SIGMA = 26;
int _w;

int son[N][SIGMA] , nidx = 1 , bac[N][SIGMA];
char str[N];
long long ans;
string s[N];

int n , pre[N][SIGMA];

int main( void ) {
  _w = scanf("%d",&n);
  for( int i = 1 ; i <= n ; ++i ) {
    _w = scanf("%s",str);
    s[i] = str;
  }
  sort( s + 1 , s + 1 + n , []( string a , string b ) { return a.length() > b.length(); } );
  for( int _i = 1 , m ; _i <= n ; ++_i ) {
    m = 0;
    for( const char & v : s[_i] )
      str[++m] = v;
    for( int i = 1 ; i <= m ; ++i ) {
      str[i] -= 'a';
      memcpy( pre[i] , pre[i - 1] , sizeof( int ) * SIGMA );
      ++pre[i][str[i]];
    }
    int u = 1;
    for( int i = m ; i > 1 ; --i ) 
      u = son[u][str[i]];
    ans += bac[u][str[1]];
    u = 1;
    for( int i = m ; i ; --i ) {
      for( int j = 0 ; j < 26 ; ++j )
        if( pre[i][j] ) ++bac[u][j];
      if( !son[u][str[i]] ) son[u][str[i]] = ++nidx;
      u = son[u][str[i]];
    }
  }
  cout << ans;
  return 0;
}
