local ffi = require("ffi") local C = ffi.C ffi.cdef[[ long long atoll(const char*); ]] local function lltonumber(str) return C.atoll(str) end local n, m, mod = io.read():match("(%d+) (%d+) (%d+)") n = tonumber(n) m = lltonumber(m) mod = lltonumber(mod) m = m % mod if m == 0LL then print(0) os.exit() end local function modpow(pow) local res = 1LL local src = m while 0LL < pow do if pow % 2LL == 1LL then res = (res * src) % mod end src = (src * src) % mod pow = pow / 2LL end return res end local ans = 1LL local s = io.read() for w in s:gmatch("%d+") do w = lltonumber(w) ans = ans * (1LL + modpow(w)) ans = ans % mod end ans = tostring(ans):gsub("LL", "") print(ans)