N = input() M = [input() for i in xrange(N)] ALL = 2**N - 1 dp = [150001]*(ALL+1) total = {1<