#include <bits/stdc++.h>   using namespace std;   long long n = 1009;   int LG2(int N) {     int ans = 0;     while (N) {       N >>= 1;       ans++;     }     return ans - 1;   }   int main() {     cin.tie(0);     cin.sync_with_stdio(0);     int n;     cin >> n;     map<string, int> M;     int o = 1;     vector<long long> v(n);     vector<string> vv(n);     int ans = 0;     for (int i = 0; i < (n); i++) {       string s;       cin >> s;       ans += s.length();       vv[i] = s;       if (M[s]) {         v[i] = M[s];       } else {         M[s] = o;         v[i] = o;         o++;       }     }     ans += n - 1;     int L = ans;     for (int f = 0; f < n; f++) {       int len = 0;       vector<long long> p;       for (int l = f; l < n; l++) {         len += vv[l].length();         if (l > f) len++;         p.push_back(v[l]);         int pL = l - f + 1;         int cntP = 0;         for (int i = l + 1; i < n; i++) {           int o = i + pL - 1;           if (o > n) continue;           int c = 0;           bool b = 1;           for (int j = i; j <= o; j++) {             if (v[j] == p[c]) {             } else {               b = 0;               break;             }             c++;           }           if (b) {             cntP++;             i = o;           }         }         if (!cntP) continue;         int rB = (len - pL) * (cntP + 1);         ans = min(ans, L - rB);       }     }     cout << ans;     return 0;   }   