import java.util.*; public class Main { static final int MOD = 1000003; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int x = sc.nextInt(); int n = sc.nextInt(); long[] values = new long[31]; int[] keys = new int[31]; values[0] = 1; values[1] = x; keys[0] = 0; keys[1] = 1; for (int i = 2; i < values.length; i++) { keys[i] = keys[i - 1] * 2; values[i] = (values[i - 1] * values[i - 1]) % MOD; } long total = 0; int[] arr = new int[n]; for (int i = 0; i < n; i++) { int y = sc.nextInt(); long sum = 1; for (int j = 30; j > 0; j--) { if (y >= keys[j]) { sum *= values[j]; sum %= MOD; y %= keys[j]; } } total += sum; total %= MOD; } System.out.println(total); } }