#include #include #include #include using namespace std; #define INF 2000000007 #define MOD 1000003 #define MAX 105 #define REP(i,n) for(int i=0;i<(n);++i) #define REPS(i,s,t) for(int i=(s);i<(t);++i) typedef unsigned int uint; typedef unsigned long long int ull; long pow(long x, int n) { //x^n 計算量O(logn) long ans = 1; while (n > 0) { if ((n & 1) == 1) { ans = (ans * x)%MOD; } x = (x * x)%MOD; //一周する度にx, x^2, x^4, x^8となる n >>= 1; //桁をずらす n = n >> 1 } return ans; } int main(){ int x,N; scanf("%d %d",&x,&N); vector a(N); REP(i,N) cin >> a[i]; uint ans = 0; for(int t : a){ ans = (ans + pow(x,t))%MOD; } cout << ans << endl; return 0; }