#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define INF 1000000000 #define EPS 1e-9 #define PI acos(-1) typedef long long ll; typedef pair P; #define MAX_N 100 #define mod 1000003 int x, N; int a[MAX_N]; ll xx[MAX_N]; void init(){ xx[1] = x; for(int i = 2; i < MAX_N; i++){ xx[i] = (xx[i-1] * xx[i-1])%mod; } } ll solve(int n){ ll ans = 1; for(int i = 0; n > 0; i++){ if(n & 1) ans = (ans*xx[i+1])%mod; n >>= 1; } return ans; } int main(){ cin >> x >> N; for(int i = 0; i < N; i++){ cin >> a[i]; } init(); ll ans = 0; for(int i = 0; i < N; i++){ ans = (ans + solve(a[i]))%mod; } cout << ans << endl; return 0; }