#include <bits/stdc++.h>

template <typename T>
T BinarySearch(T ok, T ng, std::function<bool(T)> pred) {
  while (abs(ok - ng) > 1) {
    T mid = (ok + ng) / 2;
    (pred(mid) ? ok : ng) = mid;
  }
  return ok;
}

template <typename T>
class BIT {
 public:
  BIT(int n) : v_(n) {}
  T Sum(int i) const {
    T ret = 0;
    while (i >= 0) {
      ret += v_[i];
      i = (i & (i + 1)) - 1;
    }
    return ret;
  }
  T Get(int i) const { return Sum(i) - Sum(i - 1); }
  void Add(int i, T v) {
    while (i < v_.size()) {
      v_[i] += v;
      i |= i + 1;
    }
  }

 private:
  std::vector<T> v_;
};

#if DEBUG
template <typename T>
void debug(const T& value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(const T& value, const Ts&... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                        \
  do {                                  \
    cerr << #__VA_ARGS__ << ": ";       \
    debug(__VA_ARGS__);                 \
    cerr << " (L" << __LINE__ << ")\n"; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define rd(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << '\n';
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define wt(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

template <typename T>
using V = std::vector<T>;
template <typename T>
using VV = V<V<T>>;

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  rd(int, n);

  V<string> s(n);
  rep(i, n) {
    cin >> s[i];
    reverse(all(s[i]));
  }
  sort(all(s));

  V<pair<int, int>> len(n);
  rep(i, n) len[i] = {s[i].size(), i};
  sort(all(len), greater());

  ll ans = 0;
  for (char alpha = 'a'; alpha <= 'z'; ++alpha) {
    auto lit = len.begin();
    set<int> avail_set;
    BIT<int> avail(n);
    auto add = [&](int i) {
      if (avail_set.insert(i).second) {
        avail.Add(i, 1);
      }
    };
    set<int> longer;
    for (int cl = len[0].first; cl >= 1; --cl) {
      for (int i : longer) {
        if (s[i][cl - 1] == alpha) add(i);
      }
      set<int> same;
      while (lit != len.end() && lit->first == cl) {
        same.insert(lit->second);
        ++lit;
      }
      for (int i : same) {
        if (s[i][cl - 1] == alpha) {
          string prefix = s[i].substr(0, cl - 1);
          auto match = [&](int k) {
            const string &si = s[k];
            if (si.size() < prefix.size()) return false;
            for (int j = prefix.size() - 1; j >= 0; --j) {
              if (si[j] != prefix[j]) return false;
            }
            return true;
          };
          int lo = BinarySearch<int>(i, -1, match);
          int hi = BinarySearch<int>(i, n, match);
          ans += avail.Sum(hi) - avail.Sum(lo - 1);
        }
      }
      for (int i : same) {
        if (s[i][cl - 1] == alpha) add(i);
        longer.insert(i);
      }
    }
  }
  wt(ans);
}


Measured memory_bytes: 23780