import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int x = scan.nextInt(); int N = scan.nextInt(); long []a = new long[N]; for(int i = 0; i < N; i++) { a[i] = scan.nextInt(); } scan.close(); int k = 1000003; long ans = 0; for(int i = 0; i < N; i++) { long t = x % k; if(a[i] == 0) { ans ++; ans = ans % k; }else if(a[i] == 1) { ans += x % k; }else { for(int j = 2; j <= a[i]; j++) { t = (t * x) % k; } ans = ans + t % k; ans = ans % k; } } System.out.println(ans); } }