import java.io.*; import java.util.*; import java.math.*; class Main { public static void out (Object o) { System.out.println(o); } public static int power (int x , int a , int m) { long x2 = x; long ret = 1; while (a > 0) { if (a % 2 == 1) ret = ret * x2 % m; //out("ret = " + ret + " , a = " + a + " , x2 = " + x2); a /= 2; x2 = x2 * x2 % m; } return (int)ret; } public static void main (String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String[] line1 = br.readLine().split(" "); String[] line2 = br.readLine().split(" "); int x = Integer.parseInt(line1[0]); int n = Integer.parseInt(line1[1]); int ans = 0, m = 1000003; for (int i = 0; i < n; i++) { int a = Integer.parseInt(line2[i]); ans = (ans + power(x,a,m)) % m; } out(ans); } }