module Memoizable
	def memoize(name)
		original = "__original_#{name}__"
		([Class, Module].include?(self.class) ? self : self.class).class_eval {
			alias_method(original, name)
			private(original)
			cache = {}
			define_method(name){|*args|
				cache[args] ||= send(original, *args)
			}
		}
	end 
end

def addition(s1, s2)
	match_len = s2.size-1
	match_len -= 1 until match_len == 0 || s1 =~ /#{s2[0..match_len-1]}$/
	s2.size - match_len
end

include Memoizable
memoize :addition

loop {
	n = gets.to_i
	break if n == 0
	names = (1..n).map{gets.chomp}
	trivial = []
	names.combination(2){|a, b|
		trivial << b if a =~ /#{b}/
		trivial << a if b =~ /#{a}/
	}
	trivial.uniq!
	n -= trivial.size
	names -= trivial
	
	table = [{"" => 0}]		
	(1..(1<<n)-1).each{|x|
		table[x] = Hash.new(Float::INFINITY)
		t = table[x]
		is = (0..n-1).select{|i| x[i] == 1}
		is.each{|i|
			y = x - (1 << i)
			last_name = names[i]
			table[y].each{|last, len|
				l = len + addition(last, last_name)
				t[last_name] = l if l < t[last_name]
			}
		}
	}
	p table[(1<<n)-1].values.min
}