#include using namespace std; using LL = long long; using ULL = unsigned long long; #define rep(i,n) for(int i=0; i<(n); i++) const ULL M = 1000003; ULL powm(ULL x, ULL i) { if (i == 0) return 1; ULL res = powm(x * x % M, i / 2); if (i % 2 == 1) res = res * x % M; return res; } int main() { ULL x, N; cin >> x >> N; ULL ans = 0; rep(i, N) { ULL a; cin >> a; ans += powm(x, a); } ans %= M; cout << ans << endl; return 0; }