#include using namespace std; typedef unsigned long long ul; typedef signed long long ll; ul over = 1000000007; ll apow(ll x, ll a) { ll ret = 1; vector< int > bit; while (a>0) {bit.push_back(a%2); a/=2;} for (int i = bit.size()-1; i >= 0; --i) { if (bit[i] == 1) ret *= x; if (i==0) break; ret *= ret; ret %= 1000003; } return ret; } int main(void) { cin.tie(0); ios::sync_with_stdio(false); cout << fixed; ll x, n; cin >> x >> n; ll ans = 0; for (ll i = 0; i < n; ++i) { ll a; cin >> a; ans += apow(x, a); ans %= 1000003; } cout << ans << endl; return 0; }