Problem: Recent improvements in information and communication technology have made it possible to provide municipal service to a wider area more quickly and with less costs. Stimulated by this, and probably for saving their not sufficient funds, mayors of many cities started to discuss on mergers of their cities.

There are, of course, many obstacles to actually put the planned mergers in practice. Each city has its own culture of which citizens are proud. One of the largest sources of friction is with the name of the new city. All citizens would insist that the name of the new city should have the original name of their own city at least as a part of it. Simply concatenating all the original names would, however, make the name too long for everyday use.

You are asked by a group of mayors to write a program that finds the shortest possible name for the new city that includes all the original names of the merged cities. If two or more cities have common parts, they can be overlapped. For example, if "FUKUOKA", "OKAYAMA", and "YAMAGUCHI" cities are to be merged, "FUKUOKAYAMAGUCHI" is such a name that include all three of the original city names. Although this includes all the characters of the city name "FUKUYAMA" in this order, it does not appear as a consecutive substring, and thus "FUKUYAMA" is not considered to be included in the name.



Input

The input is a sequence of datasets. Each dataset begins with a line containing a positive integer n (n ≤ 14), which denotes the number of cities to be merged. The following n lines contain the names of the cities in uppercase alphabetical letters, one in each line. You may assume that none of the original city names has more than 20 characters. Of course, no two cities have the same name.

The end of the input is indicated by a line consisting of a zero.

Output

For each dataset, output the length of the shortest possible name of the new city in one line. The output should not contain any other characters.

Examples

Input

3


Output

16


Input

3
FUKUOKA
OKAYAMA
YAMAGUCHI
3
FUKUOKA
FUKUYAMA
OKAYAMA
2
ABCDE
EDCBA
4
GA
DEFG
CDDE
ABCD
2
ABCDE
C
14
AAAAA
BBBBB
CCCCC
DDDDD
EEEEE
FFFFF
GGGGG
HHHHH
IIIII
JJJJJ
KKKKK
LLLLL
MMMMM
NNNNN
0


Output

16
19
9
9
5
70

Solution (in CPP):

Solution:
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <bitset>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef pair<int, string> P;
typedef unsigned long long ull;
const int INF = 1e9 + 7;
const int MAX_N = 14;

const ull B = 100000007;

// aはbに含まれているか
bool contain(string a, string b){
  int al = a.length(), bl = b.length();
  if(al > bl) return false;

  ull t = 1;
  REP(i, al) t *= B;

  ull ah = 0, bh = 0;
  REP(i, al) ah = ah * B + a[i];
  REP(i, al) bh = bh * B + b[i];

  for(int i = 0; i + al <= bl; ++i){
    if(ah == bh) return true; // bのi9文字目からのal文字が一致
    if(i + al < bl) bh = bh * B + b[i + al] - b[i] * t;
  }
  return false;
}

// aの末尾とbの先頭を何文字重ねることができるか
int overlap(string a, string b){
  int al = a.length(), bl = b.length();
  int ans = 0;
  ull ah = 0, bh = 0, t = 1;
  for(int i = 1; i <= min(al, bl); ++i){
    ah = ah + a[al - i] * t;
    bh = bh * B + b[i - 1];
    if(ah == bh) ans = i;
    t *= B;
  }
  return ans;
}

vector<string> make_ss(vector<string> &_ss, int N){
  vector<string> res;
  REP(i, N){
    bool f = true;
    REP(j, N){
      if(i != j && contain(_ss[i], _ss[j])) f = false;
    }
    if(f) res.push_back(_ss[i]);
  }
  return res;
}

int main(){
  int N;
  while(cin >>N && N){
    vector<string> _ss(N); REP(i, N) cin >>_ss[i];
    vector<string> ss = make_ss(_ss, N);
    N = ss.size();
    //REP(i, N) cout <<ss[i] <<", "; cout <<endl;
    int dp[(1 << MAX_N)][MAX_N];
    REP(i, (1 << MAX_N)) REP(j, N) dp[i][j] = INF;
    REP(i, N) dp[(1 << i)][i] = ss[i].length();
    int cost[MAX_N][MAX_N];
    REP(i, N) REP(j, N) cost[i][j] = (int)(ss[j].length()) - overlap(ss[i], ss[j]);
    //REP(i, N) REP(j, N) cout <<ss[i] <<", " <<ss[j] <<" = " <<cost[i][j] <<endl;
    REP(i, (1 << MAX_N)){
      REP(j, N){
        if(dp[i][j] == INF) continue;
        //cout <<i <<", " <<dp[i][j] <<endl;
        REP(b, N){
          if(i & (1 << b)) continue;
          //cout <<i <<", " <<b <<", " <<(1 << b) <<", " <<(i | (1 << b)) <<", " <<tmp <<", " <<(int)(tmp.length()) <<", " <<dp[i || (1 << b)].first <<endl;
          if(dp[i][j] + cost[j][b] < dp[i | (1 << b)][b]) dp[i | (1 << b)][b] = dp[i][j] + cost[j][b];
        }
      }
    }
    int ans = INF;
    REP(i, N) ans = min(ans, dp[(1 << N) - 1][i]);
    cout <<ans <<endl;
  }
  return 0;
}