#include using namespace std; const int MOD3 = ( int ) 1e6 + 3; signed main(){ int X, N; cin >> X >> N; int ans = 0; function< int ( int, int ) > int_pow = [ & ]( int x, int p ){ int res = 1; while( p ){ if( p & 1 ) ( res *= x ) %= MOD3; p >>= 1; ( x *= x ) %= MOD3; } return res; }; for( int i = 0; i < N; ++i ){ int A; cin >> A; ( ans += int_pow( X, A ) ) %= MOD3; } cout << ans << endl; return 0; }