import java.util.*; public class Main { static Scanner sc = new Scanner(System.in); static void myout(Object t){System.out.println(t);} static String getStr(){return sc.next();} static int getInt(){return sc.nextInt();} static Long getLong(){return sc.nextLong();} static boolean isNext(){return sc.hasNext();} public static void main(String[] args){ long x = getLong(); long N = getLong(); int mod = 1000003; long output = 0; for(int i = 0; i < N; i++){ output += originPow(x,getLong(),mod); output %= mod; } myout(output); } //便利メソッド追加枠ここから static long originPow(long x, long n,int m) { long ans = 1; while (n > 0) { if ((n & 1) == 1)ans = ans * x % m; x = x * x % m; n >>= 1; } return ans; } //便利メソッド追加枠ここまで }