import java.util.Arrays; import java.util.Scanner; public class Ruijokasan { public static void main(String[] args) { Scanner s = new Scanner(System.in); int x = s.nextInt(), N = s.nextInt(); int[] a = new int[N]; for(int i = 0;i < N;i++){ a[i] = s.nextInt(); } s.close(); int t = (int)(Math.pow(10,6) + 3); int[] xa = new int[N]; Arrays.sort(a); for(int i = 0;i < N;i++){ xa[i] = 1; for(int j = 0;j < a[i];j++){ xa[i] *= x; if(xa[i] > t){ xa[i] %= t; } } } int sum = 0; for(int i:xa){ sum += i; } System.out.println(sum%t); } }