#include using namespace std; #define M 1000003 int main() { long long x; int n; cin >> x >> n; vector a(n); for (int i = 0;i < n;i++) { cin >> a[i]; } vector nx(M+1); nx[0] = 1; int da; for (int i = 1;i <= M;i++) { nx[i] = (nx[i - 1] * x) % M; if (nx[i] == 1) { da = i; } } long long sum = 0; for (int i = 0;i < n;i++) { sum += nx[a[i] % da]; sum %= M; } cout << sum << endl; return 0; }