import java.util.*; public class Main { private static Scanner sc = new Scanner(System.in); private static long[] ary; private static final long MOD = 1000003; public static void main(String[] args) throws Exception { long x = nextLong(); int n = nextInt(); ary = nextLong(n); long ans = 0; for (int i = 0;i < n;i++) { ans = (ans+pow(x, ary[i]))%MOD; } System.out.println(ans); } private static long pow(long n, long p) { long ret = 1; while (p > 0) { if ((p&1)==1) ret = ret*n%MOD; n = n*n%MOD; p >>= 1; } return ret; } private static int nextInt() { return sc.nextInt(); } private static long nextLong() { return sc.nextLong(); } private static float nextFloat() { return sc.nextFloat(); } private static int[] nextInt(int n) { int[] ret = new int[n]; for (int i = 0;i < n;i++) { ret[i] = nextInt(); } return ret; } private static long[] nextLong(int n) { long[] ret = new long[n]; for (int i = 0;i < n;i++) { ret[i] = nextLong(); } return ret; } private static float[] nextFloat(int n) { float[] ret = new float[n]; for (int i = 0;i < n;i++) { ret[i] = nextFloat(); } return ret; } }