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

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define dbg(x) cout<<#x<<"="<<x<<endl

#define all(x) x.begin(),x.end()
#define uni(x) x.erase(unique(x.begin(),x.end()),x.end())

#define MAX_V 210
#define INF INT_MAX/3

typedef long long ll;
typedef pair<ll,ll> P;

struct edge{
  int to;
  ll cap,cost;
  int rev;
};

int V;
vector<edge> g[MAX_V];
ll h[MAX_V];
ll dist[MAX_V];
int prevv[MAX_V],preve[MAX_V];

void init(int v){
  V=v;
  for(int i=0;i<MAX_V;i++){
    g[i].clear();
  }
}

void add_edge(int from,int to,ll cap,ll cost){
  g[from].push_back((edge){to,cap,cost,(int)g[to].size()});
  g[to].push_back((edge){from,0,-cost,(int)g[from].size()-1});
}

int min_cost_flow(int s,int t,int f){
  int res=0;
  memset(h,0,sizeof(h));
  while(f>0){
    priority_queue<P,vector<P>,greater<P> > que;
    fill(dist,dist+V,INF);
    dist[s]=0;
    que.push(P(0,s));
    while(que.size()){
      P p=que.top(); que.pop();
      int v=p.second;
      if(dist[v]<p.first)continue;
      for(int i=0;i<(int)g[v].size();i++){
        edge e=g[v][i];
        if(e.cap>0&&dist[e.to]>dist[v]+e.cost+h[v]-h[e.to]){
          dist[e.to]=dist[v]+e.cost+h[v]-h[e.to];
          prevv[e.to]=v;
          preve[e.to]=i;
          que.push(P(dist[e.to],e.to));
        }
      }
    }

    if(dist[t]==INF)return -1;
    for(int v=0;v<V;v++){
      h[v]+=dist[v];
    }
    ll d=f;
    for(int v=t;v!=s;v=prevv[v]){
      d=min(d,g[prevv[v]][preve[v]].cap);
    }
    f-=d;
    res+=d*h[t];

    for(int v=t;v!=s;v=prevv[v]){
      edge &e=g[prevv[v]][preve[v]];
      e.cap-=d;
      g[v][e.rev].cap+=d;
    }
  }
  return res;
}

struct RollingHash{
  static const int MD=3;
  static const vector<ll> hash_base,hash_mod;
  int n;
  vector<ll> hs[MD], pw[MD];
  RollingHash(){}
  RollingHash(const string& s){
    n=s.size();
    rep(i,MD){
      hs[i].assign(n+1,0);
      pw[i].assign(n+1,0);
      hs[i][0]=0;
      pw[i][0]=1;
      rep(j,n){
        pw[i][j+1]=pw[i][j]*hash_base[i]%hash_mod[i];
        hs[i][j+1]=(hs[i][j]*hash_base[i]+s[j])%hash_mod[i];
      }
    }
  }

  ll hash_value(int l,int r,int i){
    return ((hs[i][r]-hs[i][l]*pw[i][r-l])%hash_mod[i]+hash_mod[i])%hash_mod[i];
  }

  bool match(int l1,int r1,int l2,int r2){
    bool ret=true;
    rep(i,MD) ret&=(hash_value(l1-1,r1,i) == hash_value(l2-1,r2,i));
    return ret;
  }

  vector<ll> calc(int l,int r){
    vector<ll> ret(MD);
    rep(i,MD) ret[i]=hash_value(l-1,r,i);
    return ret;
  }
};
const vector<ll> RollingHash::hash_base{1009,1021,1013};
const vector<ll> RollingHash::hash_mod{1000000009,1000000021,1000000033};

int main(){
  int N;
  cin>>N;
  vector<string> S(N);
  rep(i,N)cin>>S[i];
  sort(all(S));
  uni(S);
  N=S.size();
  vector<bool> dame(N,false);

  rep(i,N){
    RollingHash h1(S[i]);
    int L1=S[i].size();
    rep(j,N){
      if(i==j||S[j].size()<=S[i].size())continue;

      RollingHash h2(S[j]);
      int L2=S[j].size();
      bool matched=false;
      rep(l,L2-L1+1){
        bool matchedd=true;
        rep(k,3)if(h2.hash_value(l,l+L1,k)!=h1.hash_value(0,L1,k))matchedd=false;
        if(matchedd)matched=true;
      }
      if(matched)dame[i]=true;
    }
  }

  vector<string> T;
  rep(i,N){
    if(dame[i])continue;
    T.push_back(S[i]);
  }
  N=T.size();

  init(N*2+2);
  int source=N*2,sink=N*2+1;
  rep(i,N)rep(j,N){
    RollingHash h1(S[i]);
    RollingHash h2(S[j]);

    int mxmc=0;
    int L1=S[i].size();
    int L2=S[j].size();
    if(i==j){
      repl(l,1,min(L1,L2)){
        bool matched=true;
        rep(k,3)if(h1.hash_value(L1-l,L1,k)!=h2.hash_value(0,l,k))matched=false;
        if(matched)mxmc=max(mxmc,l);
      }
    }else{
      repl(l,1,min(L1,L2)+1){
        bool matched=true;
        rep(k,3)if(h1.hash_value(L1-l,L1,k)!=h2.hash_value(0,l,k))matched=false;
        if(matched)mxmc=max(mxmc,l);
      }
    }
    add_edge(i,j+N,1,L2-mxmc);
  }

  rep(i,N){
    add_edge(source,i,1,0);
    add_edge(i+N,sink,1,0);
  }

  cout<<min_cost_flow(source,sink,N)<<endl;

  return 0;
}



Measured memory_bytes: 4144