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 <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>
#include <cassert>
using namespace std;

//common
typedef long long ll;

#define BR "\n"
#define ALL(c) (c).begin(),(c).end()
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define EACH(it,o) for(auto it = (o).begin(); it != (o).end(); ++it)
#define IN(l,v,r) ((l)<=(v) && (v)<(r))

//config
//#undef NDEBUG
//#define INF 1<<30
//#define EPS 1e-8
//const ll MOD =100000007;

//debug
#ifdef NDEBUG
#define DUMP(x)
#define DUMPLN(x)
#define DEBUG(x)
#define DEBUGLN(x)
#define LINE()
#define LINELN()
#define CHECK(exp,act)
#define STOP(e)
#else
#define DUMP(x)  cerr << #x << " = " << (x)
#define DUMPLN(x)  DUMP(x) <<endl
#define DEBUG(x) DUMP(x) << LINE() << " " << __FILE__
#define DEBUGLN(x) DEBUG(x)<<endl
#define LINE()    cerr<< " (L" << __LINE__ << ")"
#define LINELN()    LINE()<<endl
#define CHECK(exp,act)  if(exp!=act){DUMPLN(exp);DEBUGLN(act);}
#define STOP(e)  CHECK(e,true);if(!(e)) exit(1);
#endif

template<class T> inline string toString(const vector<T>& x) {
	stringstream ss;
	REP(i,x.size()){
		if(i!=0)ss<<" ";
		ss<< x[i];
	}
	return ss.str();
}

template<class T> inline string toString(const vector<vector<T> >& map) {
	stringstream ss;
	REP(i,map.size()){
		if(i!=0)ss<<BR;
		ss<< toString(map[i]);
	}
	return ss.str();
}
template<class K,class V>  string toString(map<K,V>& x) {
	string res;stringstream ss;
	for(auto& p:x)ss<< p.first<<":" << p.second<<" ";
	return ss.str();
}

//ind -> V から V->ind (注:単射)
template<typename T>
map<T,int> rev(const vector<T>& xs){
	map<T,int> rev;
	REP(i,(int)xs.size())rev.insert(make_pair(xs[i],i));
	return rev;
}

template<typename T,typename V> inline T mod(T v,V MOD){
	return (v%MOD+MOD)%MOD;
}

int INF=1<<28;
class Main{
public:	
	int n;
	vector<vector<int>> dp;
	vector<string>  ns;

	vector<vector<int>> ds;

	void run(){
		while(true){
			cin >> n;
			if(n==0)break;
			ns=vector<string>(n);REP(i,n)  cin>> ns[i];
			
			//contain check
			vector<string> tmp;
			vector<bool> nowrap(n,true);
			REP(i,n)REP(j,n){
				if(i==j)continue;
				if(ns[i].find(ns[j])!=string::npos){
					nowrap[j]=false;
				}
			}
			REP(i,n)if(nowrap[i])tmp.push_back(ns[i]);
			ns=tmp;n=ns.size();

			ds=vector<vector<int> > (n,vector<int>(n,INF));
			REP(i,n)REP(j,n){
				int Mv=0;
				REP(p,ns[i].size()){
					int v=0;
					while(p+v<ns[i].size() &&  v<ns[j].size() && ns[i][p+v]==ns[j][v])v++;
					if(p+v!=ns[i].size())continue;
					Mv=max(Mv,v);
				}
				ds[i][j]=ns[j].size()-Mv;
			}
			dp=vector<vector<int> > (1<<n,vector<int>(n,INF));
			
			REP(i,n) dp[1<<i][i]=ns[i].size();
						
			REP(i,n) dfs((1<<n)-1,i);
			int mv=INF;
			REP(i,n) mv=min(mv,dp[(1<<n)-1][i]);

			cout << mv<<endl;
		}
	}
	void dfs(int bit,int pos){
		if(dp[bit][pos]!=INF) return;
		REP(i,n)if(( ((bit-(1<<pos))>>i) & 1) ==1){
			dfs(bit-(1<<pos),i);
		}
		int mv=INF;
		REP(i,n)if( ( ((bit-(1<<pos))>>i) & 1) ==1){
			// DUMP(dp[bit-(1<<i)][i]+ds[i][pos]);
			mv=min(mv,dp[bit-(1<<pos)][i]+ds[i][pos]);
		}
		//back
		dp[bit][pos]=mv;
	}
};

int main(){
	Main().run();
	return 0;
}