#include using namespace std; typedef long long ll; #define FOR(i,a,b) for(int i=(a);i<(int)(b);i++) #define rep(i,n) FOR(i,0,n) const int mod = 1e6 + 3; ll mod_pow(ll x, ll n, ll mod){ ll res = 1; while(n > 0){ if(n & 1) res = res * x % mod; x = x * x % mod; n >>= 1; } return res; } int main() { ll x, n; cin >> x >> n; vector a(n); for(auto& i : a) cin >> i; ll res = 0; rep(i,n){ res += mod_pow(x, a[i], mod); res %= mod; } cout << res << endl; return 0; }