import itertools x, a = map(int, input().split()) inpls = list(map(int,input().split())) def rem(x,n,d=1000003): if n == 0: return 1 else: ls = [2**i for i in range(26,-1,-1)] ac = [] for i in ls: if n - i >= 0: n -= i ac.append(i) rm = 1 for i in ac: r = x**i%d rm *= r return rm%d sm = 0 for i in inpls: sm += rem(x,i) print(sm%1000003)