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

const int64_t INF = 1e18;
struct MinCostFlow{
    struct edge {
        int64_t to, cap, cost, rev;
        edge(int64_t to, int64_t cap, int64_t cost, int64_t rev):to(to), cap(cap), cost(cost), rev(rev){}
    };

    int N, S, T;
    int64_t flow;
    int64_t cost;
    vector<vector<edge>> G;
    vector<pair<int, int>> prv; // {v, e};
    vector<int64_t> h;

    MinCostFlow(int N, int S, int T):N(N), S(S), T(T){
        flow = cost = 0;
        G.resize(N);
        prv.resize(N);
        h.resize(N);
    }

    void add_edge(int64_t from, int64_t to, int64_t cap, int64_t cost){
        G[from].emplace_back(to, cap, cost, G[to].size());
        G[to].emplace_back(from, 0, -cost, G[from].size()-1);
    }

    int64_t calculate(int64_t f){
        typedef pair<int64_t, int> P;
        
        int64_t res = 0;
        vector<int64_t> dist(N);

        while(f > flow){
            priority_queue<P, vector<P>, greater<P>> que;
            fill(dist.begin(), dist.end(), INF);
            dist[S] = 0;
            que.push({0, S});
            while(que.size()){
                auto p = que.top(); que.pop();
                int64_t d = p.first;
                int i = p.second;
                if(d > dist[i]) continue;
                for(int idx=0; idx<G[i].size(); idx++){
                    auto& e = G[i][idx];
                    int j = e.to;
                    int64_t d2 = d + e.cost + h[i] - h[j];
                    if(e.cap > 0 && dist[j] > d2){
                        dist[j] = d2;
                        prv[j] = {i, idx};
                        que.push({dist[j], j});
                    }
                }
            }
            if(dist[T] == INF) return -1;
            for(int i=0; i<N; i++) h[i] += dist[i];
            
            int64_t d = f - flow;
            for(int i=T; i!=S; i=prv[i].first){
                auto& e = G[prv[i].first][prv[i].second];
                d = min(d, e.cap);
            }
            flow += d;
            res += d * h[T];
            for(int i=T; i!=S; i=prv[i].first){
                auto& e = G[prv[i].first][prv[i].second];
                e.cap -= d;
                G[i][e.rev].cap += d;
            }
        } 
        return res;
    }
};

vector<int> z_algorithm(const vector<int>& S){
    int N = S.size(), c = 0;
    vector<int> ret(N, 0);
    for(int i=1; i<N; i++){
        if(i + ret[i-c] < c + ret[c]){
            ret[i] = ret[i-c];
        }else{
            int j = max(0, c + ret[c] - i);
            while(i+j < N && S[j] == S[i+j]) j++;
            ret[i] = j;
            c = i;
        }
    }
    ret[0] = N;
    return ret;
}

vector<int> z_algorithm(const string& S){
    int N = S.size();
    vector<int> s(N);
    for(int i=0; i<N; i++) s[i] = S[i];
    return z_algorithm(s);
}

vector<int> z_algorithm(string& A, string& B){
    string S = A + '!' + B;
    auto z = z_algorithm(S);
    vector<int> ret(B.size());
    for(int i=0; i<B.size(); i++){
        ret[i] = z[i+A.size()+1];
    }
    return ret;
}

int main(){
    int N;
    cin >> N;
    string S[100];
    for(int i=0; i<N; i++) cin >> S[i];
    int source = 200, sink = 201;
    MinCostFlow solver(sink+1, source, sink);
    for(int i=0; i<N; i++){
        solver.add_edge(source, i, 1, 0);
        solver.add_edge(100+i, sink, 1, 0);
    }
    for(int i=0; i<N; i++){
        int sz = S[i].size();
        for(int l=1; l<=sz; l++){
            bool ok = true;
            for(int s=l; s<sz; s+=l){
                int len = min(l, sz-s);
                if(S[i].substr(0, len) != S[i].substr(s, len)) ok = false;
            }
            if(ok){
                solver.add_edge(i, 100+i, 1, l);
                break;
            }
        }
    }
    for(int i=0; i<N; i++) for(int j=0; j<N; j++) if(i != j){
        int szi = S[i].size(), szj = S[j].size();
        auto z = z_algorithm(S[j], S[i]);
        z.push_back(0);
        for(int l=min(szi, szj); l>=0; l--) if(z[szi-l] == l){
            solver.add_edge(i, 100+j, 1, szj-l);
            break;
        }
    }
    int ans = solver.calculate(N);
    cout << ans << endl;
}



Measured memory_bytes: 3992