#include using namespace std; typedef long long ll; typedef long double ld; #define vt vector #define pb push_back #define mp make_pair #define mt make_tuple #define rep(i, n) rep2(i, 0, n) #define rep2(i, m, n) for (int i = m; i < (n); i++) #define maxs(x, y) (x = max(x, y)) #define mins(x, y) (x = min(x, y)) ll MOD = 1000003; ll M = 32; ll dob(ll x, ll a) { vt d(M); d[0] = 1; d[1] = x; for (ll i = 1; i < M - 1; i++) { d[i + 1] = (d[i] * d[i]) % MOD; } ll ans = 1; for (ll i = M - 1; i >= 1; i--) { if (a & (1 << (i - 1))) { ans = (ans * d[i]) % MOD; } } return ans; } int main() { ll x, N; cin >> x >> N; ll ans = 0; rep(i, N) { ll a; cin >> a; ans = (ans + dob(x, a)) % MOD; } cout << ans << endl; }