#!/usr/bin/env python3 #fileencoding: utf-8 x, _ = [int(i) for i in input().strip().split(" ")] mod = 1000003 count = 0 start = x % mod tmp = x memo = [] memo.append(start) while True: count += 1 tmp = (tmp * x)%mod if tmp == start: break memo.append(tmp) ans = 0 for i in input().strip().split(" "): a = int(i)%count ans += memo[a] ans %= mod print(ans)