#include using namespace std; using LL = long long; constexpr int MOD = 1'000'003; LL pow(LL, LL, LL); int main() { int x, N; cin >> x >> N; LL ans = 0; int a; for (int i = 0; i < N; i++) { cin >> a; ans += pow(x, a, MOD); ans %= MOD; } cout << ans << endl; } LL pow(LL a, LL b, LL m) { if (b == 0) return 1 % m; if (b == 1) return a % m; LL ret = pow(a, b / 2, m); ret = (ret * ret) % m; if (b % 2 == 1) ret = (ret * a) % m; return ret; }