#include using namespace std; typedef long long ll; int main() { int mod = 1e6+3; int x, n; cin >> x >> n; ll fact[1000000001]; fact[0] = 1; for (int i = 1; i <= 1e9; i++) fact[i] = fact[i-1] * x % mod; ll ans = 0; for (int i = 0; i < n; i++) { int a; cin >> a; ans = (ans+fact[a])%mod; } cout << ans << endl; return 0; }