#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;
class Edge{
public:
    int from, to, rev;
    Int cost, lim;
    Edge(int from, int to, Int cost, int lim = -1, Int rev = -1):
        from(from),to(to),cost(cost),lim(lim),rev(rev){}
};


class Graph{
public:
    int n;
    int m;
    vector<vector<Edge>> edge;
    Graph(int n = 0):n(n),m(0){
        edge = vector<vector<Edge>>(n);
    }
    void add_edge(int from, int to, int cost = 1, int lim = -1)
        {
            if(lim == -1){
                edge[from].push_back(Edge(from, to, cost));
                return;
            }
            edge[from].push_back(Edge(from, to, cost, lim, edge[to].size()));
            edge[to].push_back(Edge(to, from, -cost, 0, edge[from].size() - 1));
        }

};

class MinCostFlow{
public:
    priority_queue<P, vector<P>, greater<P> > pq;
    vector<Int> dist;
    vector<Int> before;
    vector<Int> index;
    MinCostFlow(){}
    
    void Dijkstra(Graph &g, Int s){
        fill(dist.begin(), dist.end(), INF);
        pq.push(P(0, s));
        dist[s] = 0;

        while(!pq.empty()){
            P tmp = pq.top();pq.pop();
            Int from = tmp.second;
            if(tmp.first > dist[from])continue;
            for(Int i = 0;i < g.edge[from].size();i++){
                auto e = g.edge[from][i];
                if(e.lim == 0)continue;
                if(dist[e.to] <= dist[from] + e.cost)continue;
                dist[e.to] = dist[from] + e.cost;
                before[e.to] =from;
                index[e.to] = i;
                pq.push(P(dist[e.to], e.to));
            }
        }
    }

    
    Int mcf(Graph &g, Int s, Int t, Int f){
        Int res = 0;
        dist = vector<Int>(g.n);
        before = vector<Int>(g.n);
        index = vector<Int>(g.n);
        while(f){
            Dijkstra(g, s);
            Int flow = f;
            for(Int now = t;now != s;){
                Int last = before[now];
                Int ind = index[now];
                auto &e = g.edge[last][ind];
                if(e.lim == 0 || e.to != now)return -1;
                flow = min(flow, e.lim);
                now = last;
            }
            for(Int now = t;now != s;){
                Int last = before[now];
                Int ind = index[now];
                auto &e = g.edge[last][ind];
                e.lim -= flow;
                g.edge[e.to][e.rev].lim += flow;
                res += e.cost * flow;
                now = last;
            }
            f -= flow;
            if(flow==0)return -1;
        }
        return res;
    }
};

bool included[1100];

int cycle(string &str){
    for(int i = 1;i < str.size();i++){
        bool ok = true;
        for(int j = 0;j + i < str.size();j++){
            if(str[j] != str[j+i]){
                ok = false;
                break;
            }
        }
        if(ok)return i;
    }
    return str.size();
}

bool incl(string &a, string &b){
    for(int i = 0;i + a.size() <= b.size();i++){
        bool ok = true;
        for(int j = 0;j < a.size();j++){
            if(a[j] != b[i+j]){
                ok = false;
                break;
            }
        }
        if(ok)return true;
    }
    return false;
}

int after(string &a, string &b){
    for(int i = 1;i < a.size();i++){
        bool ok = true;
        for(int j = i;j < a.size();j++){
            if(j-i >= b.size() || b[j-i] != a[j]){
                ok = false;
                break;
            }
        }
        if(ok)return i;
    }
    return a.size();
    
}

Int n, flow;
string str[110];

int main(){
    cin >> n;
    for(int i = 0;i < n;i++) cin >> str[i];

    Graph g(n * 2 + 2);
    
    Int S = n*2, T = n * 2 + 1;
    for(int i = 0;i < n;i++){
        for(int j = 0;j < n;j++){
            if(str[i].size() < str[j].size()){
                if(incl(str[i], str[j]))included[i] = true;
            }
        }
    }
    for(int i = 0;i < n;i++){
        if(included[i])continue;
        for(int j = 0;j < n;j++){
            if(included[j])continue;
            if(i == j){
                g.add_edge(i, j+n, cycle(str[i]), 1);
            }
            else{
                g.add_edge(i, j+n, after(str[i], str[j]), 1);
            }

        }
    }
    for(int i = 0;i < n;i++){
        if(included[i])continue;
        flow++;
        g.add_edge(S, i, 0, 1);
        g.add_edge(i + n, T, 0, 1);
    }
    MinCostFlow mcf;
    
    cout << mcf.mcf(g, S, T, flow) << endl;
  
    return 0;
}



Measured memory_bytes: 3924