def keisan(x, N, a): result = 0 for i in range(N): result += x ** a[i] return result % 1000003 def main(): x, N = map(int, input().split()) a_li =list(map(int, input().split())) print(keisan(x, N, a_li)) if __name__ == '__main__': main()