import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; public class No16 { static long K = 1000003; public static void main(String[] args) throws IOException{ //累乗の加算 String[] text = readStr(); Long x = Long.parseLong(text[0].split(" ")[0]) , a; int N = Integer.parseInt(text[0].split(" ")[1]); long sum = 0; for(int i = 0;i < N;i++) { a = Long.parseLong(text[1].split(" ")[i]); sum += div(x , a); sum %= K; } System.out.println(sum); } public static long div(long x , long a) { long ans , c = 1; if(x <= 1) { ans = x; }else { while((long)Math.pow(x, c) < K) c++; if(c > a) { ans = (long)Math.pow(x, a); }else { ans = (div((long)Math.pow(x, c) % K , a / c) * (long)Math.pow(x, a % c)) % K; } } return ans; } public static String[] readStr() throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); ArrayList list = new ArrayList<>(); do { list.add(br.readLine()); }while(br.ready()); br.close(); String[] text = new String[list.size()]; list.toArray(text); return text; } }