using System; using System.Linq; namespace yukicoder { class Program { static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); int[,] F = new int[n, n]; bool[] used = new bool[n]; int max = -1; int ans = 0; int ii = 0; int jj = 0; for (int i = 0; i < n; i++) { string[] lines = Console.ReadLine().Split(' '); for (int j = 0; j < n; j++) { F[i, j] = int.Parse(lines[j]); } } while (used.Any(b => b == false)) { max = -1; for (int i = 0; i < n; i++) { if (used[i]) { continue; } for (int j = 0; j < n; j++) { if (used[j]) { continue; } if (max < F[i, j]) { max = F[i, j]; ii = i; jj = j; } } } used[ii] = true; used[jj] = true; ans += max; } Console.WriteLine(ans); } } }