import java.math.BigInteger; import java.util.Scanner; public class No16 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); BigInteger x, a, ans, mod; int N; x = new BigInteger(sc.next()); N = sc.nextInt(); mod = new BigInteger("1000003"); ans = new BigInteger("0"); for (int i = 0; i < N; i++) { a = new BigInteger(sc.next()); ans = ans.add(x.modPow(a, mod)); ans = ans.mod(mod); } System.out.println(ans); } }