import future, strutils proc nextString: string = result = "" while not endOfFile stdin: let nextChar = readChar stdin case nextChar of '\r': discard of "\n"[0], ' ': break else: add result, nextChar proc nextInt: int = return parseInt nextString() proc gcd(x, y: int): int = var (a, b) = (x, y) if b > a: swap(a, b) while true: let c = a mod b if c == 0: return b a = b b = c let n = nextInt() a = lc[nextInt() | (x <- 0..