import strutils, sequtils, math var a = newSeq[int64](100010) proc f(i, n: int, b: seq[int64]): bool = if i > n: return true if i mod 2 == 0: a[i] = a[i-1] - b[i-1] if a[i] <= 0 or 10^18 < a[i]: return false return f(i+1, n, b) else: a[i] = b[i-1] - a[i-1] if a[i] <= 0 or 10^18 < a[i]: return false return f(i+1, n, b) when isMainModule: var n = stdin.readLine.parseInt b = newSeq[int64](n) for i in 0..n-1: b[i] = stdin.readLine.parseBiggestInt if n == 1: if b[0] <= 1: echo "-1" else: echo 2 echo 1 echo b[0] - 1 quit() var l: int64 = -1 u: int64 = b[0] while u - l > 1: let m: int64 = (u + l) div 2 a[0] = m if f(1, n, b): l = m else: u = m for i in max(1, l-100)..min(b[0]-1, u+100): a[0] = i if f(1, n, b): echo n+1 for i in 0..n: echo a[i] if not (1 <= a[i] and a[i] <= 10^18): discard a[-1] if i == n: continue if i mod 2 == 0: if not (a[i] + a[i+1] == b[i]): discard a[-1] else: if not (a[i] - a[i+1] == b[i]): discard a[-1] quit() echo "-1"