//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}


template<int char_size, int base>
struct Trie {
  struct Node {
    vector<int> nex, accept;
    int c, common;
    //
    vi al;//
    Node(int c_) : c(c_), common(0) {
      nex.assign(char_size, -1);
      //
      al.assign(26, 0);//
    }
  };

  vector<Node> nodes;
  int root;
  Trie() : root(0) {
    nodes.assign(1, Node(root));
  }

  void insert(const string &word, int word_id) {
    //
    int aal[26] = {};
    rep(i, word.size()) {
      aal[word[i]-base]++;
    }//
    int node_id = 0;
    for(int i = 0; i < (int)word.size(); i++) {
      int c = word[i] - base;
      int &next_id = nodes[node_id].nex[c];
      //
      rep(j, 26) if(aal[j]) nodes[node_id].al[j]++;
      aal[c]--;//
      if(next_id == -1) {
        next_id = nodes.size();
        nodes.emplace_back(Node(c));
      }
      ++nodes[node_id].common;
      node_id = next_id;
    }
    ++nodes[node_id].common;
    nodes[node_id].accept.emplace_back(word_id);
  }
  inline void insert(const string &word) {
    insert(word, nodes[root].common);
  }

  bool search(const string &word, bool prefix = false) {
    int node_id = 0;
    for(int i = 0; i < (int)word.size(); i++) {
      int c = word[i] - base;
      int &next_id = nodes[node_id].nex[c];
      if(next_id == -1) {
        return false;
      }
      node_id = next_id;
    }
    return prefix ? true : !nodes[node_id].accept.empty();
  }

  inline bool start_with(const string &prefix) {
    return search(prefix, true);
  }

  //
  int query(const string &word) {
    int node_id = 0;
    for(int i = 0; i < (int)word.size()-1; i++) {
      int c = word[i] - base;
      int &next_id = nodes[node_id].nex[c];
      if(next_id == -1) {
        return 0;
      }
      node_id = next_id;
    }
    return nodes[node_id].al[word[word.size()-1] - base];
  }//

  int count() const {
    return nodes[0].common;
  }

  size_t size() const {
    return nodes.size();
  }
};

//head

int n;
ll ans;
Trie<26,'a'> rie;
const int N = 2e5+10;
string s[N];

bool co(const string &s, const string &t) {return s.size() > t.size();}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  rep(i, n) cin >> s[i];
  sort(s, s+n, co);
  rep(i, n) {
    string &s_ = s[i];
    reverse(all(s_));
    ans += rie.query(s_);
    rie.insert(s_);
    //cout << ans << endl;
  }
  cout << ans << endl;
}

Measured memory_bytes: 306968