#include using namespace std; using ll = long long; using vi = vector; using vb = vector; using vd = vector; using vl = vector; using vvi = vector; using vvb = vector; using vvd = vector; using vvl = vector; #define REP(i,n) for(ll i=0; i<(n); ++i) #define TEN(x) ((ll)1e##x) #define MOD (TEN(6) + 3) template struct GF{ ll v; GF(ll v = 0) : v((v % mod + mod) % mod){} GF operator+(GF x){return v + x.v;} GF pow(ll n) { ll x = v, r = 1; for (; n > 0; n >>= 1) { if (n & 1) (r *= x) %= mod; (x *= x) %= mod; } return r; } }; int main() { ll _x, n; cin >> _x >> n; GF x(_x); GF sum = 0; REP(i, n) { ll a; cin >> a; sum = sum + x.pow(a); } cout << sum.v << endl; return 0; }