import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; public class No16_2 { static int K = 1000003; public static void main(String[] args) throws IOException{ //累乗の加算  二分累乗法で作り直し String[] text = readStr(); int x = Integer.parseInt(text[0].split(" ")[0]); int N = Integer.parseInt(text[0].split(" ")[1]) , a , i , len; int sum = 0 , rui; int[] r = new int[32]; String bit; r[0] = x; for(i = 1;i < 32;i++) { r[i] = (int)((long)Math.pow(r[i - 1], 2) % K); } for(i = 0;i < N;i++) { rui = 1; a = Integer.parseInt(text[1].split(" ")[i]); bit = Integer.toBinaryString(a); len = bit.length(); for(int k = 0;k < len;k++) { if(bit.charAt(k) == '1') { rui = (int)((long)rui * (long)r[len - k - 1] % K); } } sum = (sum + rui) % K; } System.out.println(sum); } 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; } }