import sequtils, strutils, math proc powmod[T](x, k, m: T): T = if k == 0: result = 1 elif k mod 2 == 0: let x = powmod(x, k shr 1, m) result = x * x mod m else: result = powmod(x, k-1, m) * x mod m let m = 1000003 t = stdin.readline.split.map(parseInt) (x, N) = (t[0], t[1]) stdin.readline.split.mapIt(x.powmod(it.parseInt, m)).sum.echo