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); } static long powMod(int a, int n) { long res = 1; for (int i = 0; i < n; i++) { res = a * (res % 1000003); } return res; } }