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 <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

class Graph{
	private:
	int n;
	vector<vector<pair<int,double>>> g;
	public:
	vd DIJ(int s){
		priority_queue<pair<double,int>> q;
		vd d(n,inf);
		d[s]=0;
		q.push(make_pair(0,s));
		while(!q.empty()){
			auto p=q.top();
			q.pop();
			int v=p.second;
			if(d[v]<-p.first) continue;
			for(auto i:g[v]){
				int u=i.first;
				double D=d[v]+i.second;
				if(d[u]>D){
					d[u]=D;
					q.push({-D,u});
				}
			}
		}
		return d;
	}
	Graph(int v){
		n=v;
		g=vector<vector<pair<int,double>>>(v);
	}
	void add_edge(int s,int t,double c){
//		cout<<s<<' '<<t<<' '<<syosu(9)<<c<<endl;
		g[s].push_back(make_pair(t,c));
	}
};

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	while(1){
		int n;
		cin>>n;
		if(n==0) break;
		vs a(n);
		for(auto &i:a) cin>>i;
		vs a_;
		for(int i=0;i<n;i++){
			bool B=1;
			int m1=a[i].size();
			for(int j=0;j<n;j++) if(j!=i&&a[j].size()>=m1){
				int m2=a[j].size();
				for(int k=0;k<m2;k++) if(a[j].substr(k,m1)==a[i]) B=0;
			}
			if(B) a_.push_back(a[i]);
		}
		a=a_;
		n=a.size();
		int N=1<<n;
		vvi dp(N,vi(n,inf));
		vvi b(n,vi(n));
		for(int i=0;i<n;i++) for(int j=0;j<n;j++) if(i!=j){
			int m1=a[i].size(),m2=a[j].size();
			b[i][j]=m2;
			for(int k=m1-1;k>=0;k--) if(a[i].substr(k,m1-k)==a[j].substr(0,m1-k)){
				b[i][j]=m2-m1+k;
			}
		}
/*		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++) cout<<b[i][j]<<' ';
			cout<<endl;
		}*/
//		for(auto i:a) cout<<i<<endl;
		for(int i=0;i<n;i++) dp[1<<i][i]=a[i].size();
		for(int i=0;i<N;i++) for(int j=0;j<n;j++) if(dp[i][j]<inf){
			for(int k=0;k<n;k++) if(!(i&1<<k)){
				int I=i+(1<<k);
				dp[I][k]=min(dp[I][k],dp[i][j]+b[j][k]);
//				if(dp[i][j]+b[j][k]==18) cout<<i<<' '<<j<<' '<<k<<endl;
			}
		}
		int res=inf;
		for(int i=0;i<n;i++){
			res=min(res,dp[N-1][i]);
		}
		cout<<res<<endl;
/*		for(int i=0;i<N;i++){
			for(auto j:dp[i]) cout<<j<<' ';
			cout<<endl;
		}*/
	}
}