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) proc powM(x, n: int): int = if n == 0: return 1 result = powM(x ^ 2 mod M, n div 2) if n mod 2 == 1: result = result * x mod M for i, a_i in a: ttl[i] = powM(x, a_i) echo ttl.sum