#include #include #include #include #include #include #include #include #include #include #include #include #include #include #define rep(i, a, b) for (int i = (a); i < (b); ++i) #define all(x) (x).begin(), (x).end() #define MOD 1000000007 #define int long long using ll = long long; using namespace std; const int INF = 1LL << 50; using P = pair; template bool chmin(T &a, T b) { if (a > b) { a = b; return true; } else { return false; } } template bool chmax(T &a, T b) { if (a < b) { a = b; return true; } else { return false; } } struct Setup { Setup() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); } } SETUP; constexpr int Mod = 1000003; int repeat_pow(int n, int p, int mod) { if (p <= 0) return 1; if (p % 2 == 0) { int t = repeat_pow(n, p / 2, mod); return t * t % mod; } else { return n * repeat_pow(n, p - 1, mod); } } signed main() { int x, n; cin >> x >> n; int sum = 0; rep(i, 0, n) { int a; cin >> a; sum += repeat_pow(x, a, Mod); } cout << sum << endl; }