import sequtils template times*(n:int,body) = (for _ in 0.." .} proc scan(): int = while true: let k = getchar_unlocked() if k < '0': return result = 10 * result + k.ord - '0'.ord const INF = 1e10.int let n = scan() let S = newSeqWith(n,scan()) let m = scan() var E = newSeqWith(n,newSeqWith(n,INF)) m.times: let src = scan() let dst = scan() let cost = scan() E[src][dst] = cost E[dst][src] = cost # ワーシャルフロイド => A->Bの距離がわかる # A,Bに滞在するとして 0->A->B->Nの最低コストが解 var ans = INF for k in 0..