#pragma GCC target("sse4,avx,tune=native") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include #include #define MOD 1'000'003 using namespace std; constexpr unsigned int pow_mod(const unsigned long long a, const unsigned long long b, const unsigned int mod) { return (b == 0 ? (mod == 1 ? 0 : 1) : (b & 1 ? a % mod : 1) * pow_mod((a % mod) * (a % mod) % mod, b >> 1, mod) % mod); } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); uint16_t x, N, i; uint32_t a[100], ans = 0; cin >> x >> N; for (i = 0; i != N; ++i) cin >> a[i]; for (i = 0; i != N; ++i) ans = (ans + pow_mod(x, a[i], MOD)) % MOD; cout << ans << '\n'; return 0; }