#include using namespace std; #define SIZE 100 #define MOD 1000003 int calcPowMod(int x, int n, int mod); int main (void) { int i, x, N = 0; int a[SIZE]; unsigned long ans = 0; cin >> x >> N; for ( i = 0; i < N; i++ ) { cin >> a[i]; } for ( i = 0; i < N; i++ ) { ans += calcPowMod(x, a[i], MOD); } cout << ans << endl; } int calcPowMod(int x, int n, int mod) { unsigned long sum; if ( n == 0 ) { return 1; } if ( n == 1 ) { return x % mod; } sum = calcPowMod(x, n/2, mod); cout << sum << endl; return n%2 == 0 ? (sum * sum) % mod : (x * sum * sum) % mod; }