#include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define REP(i,a,n) for(int i=(a); i<(int)(n); i++) #define rep(i,n) REP(i,0,n) #define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it) #define ALLOF(c) (c).begin(), (c).end() typedef long long ll; #define MOD 1000003 ll mod_pow(ll x, ll n){ ll res = 1; while(n>0){ if(n&1) res = res*x%MOD; x = x*x%MOD; n >>= 1; } return res; } int main(){ int N; ll x, a; vector A; cin >> x >> N; rep(i,N){ cin >> a; A.push_back(a); } ll ret = 0; rep(i,N){ ret += mod_pow(x, A[i]); ret %= MOD; } cout << ret << endl; return 0; }