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