#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define INF (1 << 30) #define INFLL (1LL << 60) int main() { long long x,n,a,ans = 0; cin >> x >> n; for(int i = 0;i < n;i++){ cin >> a; long long num = x; if(a == 0) num = 1; for(int j = 1;j < a;j++){ if(a % j == 0){ num = num * num % 1000003; j = 2*j-1; continue; } num = num * x % 1000003; } ans += num; } cout << ans % 1000003 << endl; return 0; }