#include using namespace std; void fast_io() { cin.tie(nullptr); ios_base::sync_with_stdio(false); } std::ostream &operator<<(std::ostream &dest, __int128_t value) { std::ostream::sentry s(dest); if (s) { __uint128_t tmp = value < 0 ? -value : value; char buffer[128]; char *d = std::end(buffer); do { --d; *d = "0123456789"[tmp % 10]; tmp /= 10; } while (tmp != 0); if (value < 0) { --d; *d = '-'; } int len = std::end(buffer) - d; if (dest.rdbuf()->sputn(d, len) != len) { dest.setstate(std::ios_base::badbit); } } return dest; } __int128 parse(string &s) { __int128 ret = 0; for (int i = 0; i < s.length(); i++) if ('0' <= s[i] && s[i] <= '9') ret = 10 * ret + s[i] - '0'; return ret; } using llint = __int128_t; llint pow_mod(llint a, llint n, llint m) { llint ret = 1; while (n) { if (n % 2) { ret = ret * a % m; } a = a * a % m; n /= 2; } return ret; } int main() { fast_io(); long long n, m, b; cin >> n >> m >> b; llint ans = 1; for (int i = 0; i < n; i++) { long long a; cin >> a; llint mul = (pow_mod(m, a, b) + 1) % b; ans = ans * mul % b; } cout << ans << endl; }