import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int x = sc.nextInt(); int n = sc.nextInt(); int[] r = new int[1000002]; r[0] = 1; for(int i = 1; i < 1000002; i++) { r[i] = (r[i - 1] * x) % 1000003; } int ans = 0; for(int i = 0; i < n; i++) { int a = sc.nextInt(); a = a % 1000002; ans = (ans + r[a]) % 1000003; } System.out.println(ans); } }