import sequtils,strutils,algorithm type bound = tuple[a : int,b : int,value : int] var N = stdin.readline.parseInt A = newSeqWith(N,newSeq[int](0)) ans : int T : seq[int] unit,unit2 : bound flag = newSeqWith(N,false) Units = newSeq[bound](0) flag2 = true Max_units = Units for n in 0.. u.value + u2.value and A[u.a][u2.b] + A[u.b][u2.a] > A[u.a][u2.a] + A[u.b][u2.b]: Max_units[i] = (u.a,u2.b,A[u.a][u2.b]) Max_units[j] = (u.b,u2.b,A[u.b][u2.a]) flag2 = true elif A[u.a][u2.a] + A[u.b][u2.b] > u.value + u2.value: Max_units[i] = (u.a,u2.a,A[u.a][u2.a]) Max_units[j] = (u.b,u2.b,A[u.b][u2.b]) flag2 = true ans = 0 for u in Max_units: ans += u.value echo ans