#include using namespace std; #define FOR(i,s,e) for(int (i)=(s);(i)<(e);(i)++) #define FORR(i,s,e) for(int (i)=(s);(i)>(e);(i)--) #define MOD 1000003 typedef long long llong; /* typedef vector VI typedef vector VD typedef vector VS typedef */ /* 2進数で操作し、 1が立つところのみx^(n(2)bit部)を取り出す*/ llong powmod(llong x, int n, int mod) { llong res = 1; while (n > 0) { if (n & 1) { res =(res*x)%mod; } x = (x*x)%mod; n >>= 1; } return res; } int main() { cin.tie(0); ios_base::sync_with_stdio(false); int x, N; llong ans=0; cin >> x >> N; FOR(i, 0, N) { int a; cin >> a; ans += powmod(x, a, MOD); } cout << ans%MOD << endl; return 0; }