import java.util.Arrays; import java.util.Scanner; public class No16 { public static final long mod = 1000003; public static void main(String[] args) { Scanner sc = new Scanner(System.in); long x = sc.nextLong(); int N = sc.nextInt(); long a[] = new long[N]; for(int i = 0;i < N;i++) { a[i] = sc.nextLong(); } Arrays.sort(a); String s = Long.toBinaryString(a[N-1]); long a2[] = new long[s.length()]; a2[0] = x; for(int i = 1;i < s.length();i++) { a2[i] = a2[i-1] * a2[i-1] % mod; } long sum = 0; for(int i = 0;i < N;i++) { long z = 1; s = Long.toBinaryString(a[i]); StringBuffer sb = new StringBuffer(s); s = sb.reverse().toString(); for(int j = 0;j < s.length();j++) { if(s.charAt(j) == '1') { z = z * a2[j] % mod; } } sum = (sum + z) % mod; } System.out.println(sum); } }