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); Arrays.sort(a); for(int i = 1;i < N;i++){ for(int j = 0;j < i;j++){ a[i] -= a[j]; } } int sum = 1; for(int i = N-1;i >= 0;i--){ for(int j = 0;j < a[i];j++){ sum *= x; if(sum > t){ sum %= t; } } if(i == 0){ break; } sum++; } System.out.println(sum); } }