using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int NN => int.Parse(ReadLine()); static int[] NList => ReadLine().Split().Select(int.Parse).ToArray(); static int[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray(); public static void Main() { Solve(); } static void Solve() { var n = NN; var a = NList; var b = NArr(n); var bitmax = 1 << n; var ans = long.MinValue; var alist = new List(); for (var i = 1; i < bitmax; ++i) { var tmp = i; var list = new List(); for (var j = 0; j < n; ++j) { if (tmp % 2 == 1) list.Add(j); tmp >>= 1; } var sum = 0L; for (var j = 0; j < list.Count; ++j) { sum += a[list[j]]; for (var k = j + 1; k < list.Count; ++k) sum += b[list[j]][list[k]]; } if (ans < sum) { ans = sum; alist = list; } } WriteLine(ans); WriteLine(string.Join(" ", alist.Select(ai => ai + 1))); } }