#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long int ll; typedef unsigned long long int llu; typedef pair pii; typedef vector vi; typedef vector > vii; #define rrep(i, m, n) for(int i=m; i=m; i--) #define erev(i, n) for(int i=n; i>=1; i--) #define rev(i, n) for(int i=n-1; i>=0; i--) #define FOREACH(v) (v).begin(), (v).end #define CNT(a, n, x) (upper_bound(a, a+n, x)-lower_bound(a, a+n, x)) #define minup(m, x) (m=min(m, x)) #define maxup(m, x) (m=max(m, x)) #define INF 1000000000 #define MOD 1000003 #define EPS 1E-8 ll modPow(ll x, ll n, ll mod); ll x; int n; ll a; ll res; int main() { cin >> x >> n; rep(i, n){ cin >> a; res = (res + modPow(x, a, MOD)) % MOD; } cout << res << endl; return 0; } ll modPow(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; }