import java.util.*; public class Main { static Scanner sc; final static int MOD = 1000003; static long pow_mod(long a, long p) { if (p == 0) return 1; if (p % 2 == 1) return a * pow_mod(a, p - 1) % MOD; long t = pow_mod(a, p / 2); return t * t % MOD; } public static void main(String[] args) { sc = new Scanner(System.in); long ans = 0; int x = sc.nextInt(); int N = sc.nextInt(); for (int i = 0; i < N; i++) { int buf = sc.nextInt(); ans = (ans + pow_mod(x, buf)) % MOD; } System.out.println(ans); return; } }