import sequtils,strutils,algorithm,math,sugar,macros,strformat proc getchar_unlocked():char {. importc:"getchar_unlocked",header: "" .} proc scan(): int = while true: var k = getchar_unlocked() if k < '0': break result = 10 * result + k.ord - '0'.ord let n = scan() let A = newSeqWith(n,scan()) let B = A.sorted(cmp) var C = A var results = newSeq[(int,int)]() for i in 0..