#include <bits/stdc++.h>
using namespace std;
const long long charbase = 'A';
struct RollingHash {
  long long Mod[2], Base[2];
  long long ssize, maxssize;
  string s;
  vector<long long> pow[2];
  vector<long long> hash[2];
  RollingHash(string inis = "") {
    Mod[0] = 1000000007;
    Mod[1] = 1000000009;
    Base[0] = 1009;
    Base[1] = 1007;
    maxssize = inis.size() + 10;
    for(int t = 0; t < 2; ++t) {
      pow[t].assign(maxssize, 0);
      pow[t][0] = 1;
      for(int i = 1; i < maxssize; ++i)
        pow[t][i] = pow[t][i - 1] * Base[t] % Mod[t];
    }
    init(inis);
  }
  void init(string inis = "") {
    s = inis;
    ssize = s.size();
    sethash();
  }
  void sethash() {
    ssize = s.size();
    for(int t = 0; t < 2; ++t) {
      hash[t].assign(ssize + 1, 0);
      for(int i = 0; i < ssize; ++i) {
        if(i != 0)
          hash[t][i + 1] = hash[t][i] * Base[t] % Mod[t];
        hash[t][i + 1] += (s[i] - charbase);
        hash[t][i + 1] %= Mod[t];
      }
    }
  }
  // [l,r),0-indexed
  pair<long long, long long> calchash(int l, int r) {
    long long ans[2];
    for(int t = 0; t < 2; ++t) {
      ans[t] = hash[t][r];
      ans[t] -= hash[t][l] * pow[t][r - l] % Mod[t];
      while(ans[t] < 0) ans[t] += Mod[t];
      ans[t] %= Mod[t];
    }
    return make_pair(ans[0], ans[1]);
  }
};

template <class T>
struct Primal_Dual {
  using Pa = pair<T, int>;
  const int infinity = (int)(1e9);
  struct edge {
    int to;
    T cap, cost;
    int rev;
  };
  int v;
  vector<vector<edge>> edges;
  vector<T> h;
  vector<T> dist;
  vector<int> prevv, preve;
  Primal_Dual(int vsize = 1) {
    v = vsize;
    edges.resize(v);
    h.resize(v);
    dist.resize(v);
    prevv.resize(v);
    preve.resize(v);
  }
  bool add(int from, int to, T cap, T cost) {
    edges[from].push_back(
        (edge){to, cap, cost, (int)edges[to].size()});
    edges[to].push_back((edge){
        from, 0, -cost, (int)edges[from].size() - 1});
    return 1;
  }
  T solve(int s, int t, T f) {
    T ans = 0;
    h.assign(v, 0);
    while(f > 0) {
      priority_queue<Pa, vector<Pa>, greater<Pa>> qu;
      dist.assign(v, infinity);
      dist[s] = 0;
      qu.push({0, s});
      while(!qu.empty()) {
        Pa now = qu.top();
        qu.pop();
        int nowv = now.second;
        if(dist[nowv] < now.first) continue;
        for(int i = 0; i < (int)edges[nowv].size(); ++i) {
          edge &e = edges[nowv][i];
          if(e.cap > 0 && dist[e.to] > dist[nowv] + e.cost +
                                           h[nowv] -
                                           h[e.to]) {
            dist[e.to] =
                dist[nowv] + e.cost + h[nowv] - h[e.to];
            prevv[e.to] = nowv;
            preve[e.to] = i;
            qu.push({dist[e.to], e.to});
          }
        }
      }
      if(dist[t] == infinity) return -1;
      for(int i = 0; i < v; ++i) h[i] += dist[i];
      T d = f;
      for(int i = t; i != s; i = prevv[i])
        d = min(d, edges[prevv[i]][preve[i]].cap);
      f -= d;
      ans += d * h[t];
      for(int i = t; i != s; i = prevv[i]) {
        edge &e = edges[prevv[i]][preve[i]];
        e.cap -= d;
        edges[i][e.rev].cap += d;
      }
    }
    return ans;
  }
};

long long n;
vector<string> s;
vector<RollingHash> rh;

long long solve();

int main() {
  cin >> n;
  s.resize(n);
  for(int i = 0; i < n; ++i) cin >> s[i];
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long ans = 0;
  Primal_Dual<long long> pd(2 * n + 2);
  rh.resize(n);
  for(int i = 0; i < n; ++i) {
    ans += s[i].size();
    pd.add((int)2 * n, i, 1LL, 0LL);
    pd.add(i + n, (int)2 * n + 1, 1LL, 0LL);
    rh[i] = RollingHash(s[i]);
  }
  for(int i = 0; i < n; ++i)
    for(int j = 0; j < n; ++j) {
      int nowcost = 0;
      for(int k = 1;
          k <= (int)min(s[i].size(), s[j].size()); ++k)
        if(rh[i].calchash(s[i].size() - k, s[i].size()) ==
           rh[j].calchash(0, k)) {
          if(i == j && k == (int)s[i].size()) continue;
          nowcost = k;
        }
      pd.add(i, j + n, 1, (int)s[j].size() - nowcost);
    };
  return pd.solve((int)2 * n, (int)2 * n + 1, (int)n);
}


Measured memory_bytes: 7160