import java.util.Arrays; import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Scanner; import java.util.Set; public class Main { public static final long MOD = 1000003L; public static long mod_pow(final long x, final long a, final long mod){ if(a == 0){ return 1l; }else if(a == 1){ return x; }else if(a % 2 != 0){ return (x * mod_pow(x, a - 1, mod)) % mod; }else { final long ret = mod_pow(x, a / 2, mod); return (ret * ret) % mod; } } public static void main(String[] args){ Scanner sc = new Scanner(System.in); final long x = sc.nextLong(); final int N = sc.nextInt(); long sum = 0; for(int i = 0; i < N; i++){ sum += mod_pow(x, sc.nextLong(), MOD); } System.out.println(sum); } }