import std.algorithm, std.array, std.container, std.range; import std.string, std.conv, std.math; import std.stdio, std.typecons; const long mod = 1000003; void main() { auto rd = readln.split.map!(to!long); auto x = rd[0]; auto n = rd[1]; auto ai = readln.split.map!(to!long).array; auto pow_table = [x]; writeln(ai.map!(a => pow(x, a, pow_table)).sum % mod); } long pow(long x, long n, long[] pow_table) { auto c = 1; for (auto r = 1; n > 0; (r += 1, n >>= 1)) { if (pow_table.length < r) pow_table ~= (pow_table.back ^^ 2) % mod; if ((n & 1) == 1) c = (c * pow_table[r - 1]) % mod; } return c; }