import strutils, sequtils, math const M = 10 ^ 6 + 3 let xN, a = stdin.readLine.split.map parseInt (x, N) = (xN[0], xN[1]) var ttl = newSeq[int](N) for i, a_i in a: var y = 1 for j in 0 ..< a_i: y = (y * x) mod M ttl[i] = y echo ttl.sum