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