from math import inf def main(): N = int(input()); INF = float("inf") A = list(map(int,input().split())) B = [list(map(int,input().split())) for _ in range(N)] mx = -INF idx = -1 for i in range(1<>j)&1 == 1: score += A[j] for p in range(N): for q in range(p+1,N): if (i>>p)&1 == 1 and (i>>q)&1 == 1: score += B[p][q] if score > mx: mx = score idx = i if mx == -INF: print(0) ret = [] print(*ret) exit() print(mx) ret = [] for i in range(N): if (idx>>i)&1 == 1: ret.append(i+1) #1-index print(*ret) if __name__ == '__main__': main()