import java.util.Scanner; public class Yukicoder16 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int x = sc.nextInt(); int N = sc.nextInt(); long res = 0; for (int i = 0; i < N; i++) { res += powMod(x, sc.nextInt()) % 1000003; } System.out.println(res % 1000003); } private static long powMod(long a, int n) { long res = 1; for (; n > 0; n>>=1) { res = (n & 1) == 1 ? (a * res) % 1000003 : res; a = (a * a) % 1000003; } return res; } }