import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Scanner; public class No16 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long x = sc.nextLong(); int N = sc.nextInt(); List a = new ArrayList(); for(int i = 0;i < N;i++) { a.add(sc.nextLong()); } Collections.sort(a); long xn = 1; long sum = 0; for(long i = 0;i <= a.get(a.size()-1);i++) { if(i != 0) { xn = xn * x % 1000003; } if(a.indexOf(i) != -1) { sum = (sum + xn) % 1000003; } } System.out.println(sum); } }