// #pragma GCC target("avx2") // #pragma GCC optimize("O3") // #pragma GCC optimize("unroll-loops") #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using lg = long long; using pii = pair; using pll = pair; #define TEST cerr << "TEST" << endl #define AMARI 998244353 // #define AMARI 1000000007 #define TEMOTO ((sizeof(long double) == 16) ? false : true) #define TIME_LIMIT 1980 * (TEMOTO ? 1 : 1000) #define mpr make_pair #define el '\n' #define El '\n' lg bekizyou(lg a,lg b,lg m){ lg ans = 1,temp = a % m; while(b){ if(b % 2){ ans *= temp; ans %= m; } temp *= temp; temp %= m; b /= 2; } return ans; } #define MULTI_TEST_CASE false void solve(void) { int n; lg m,b; cin >> n >> m >> b; m %= b; vector a(n); for(int i = 0; i < n; i++){ cin >> a[i]; //a[i] %= b; } lg ans = 1; //cerr << bekizyou(1,1,2) << El; for(int i = 0; i < n; i++){ lg temp = 1 + bekizyou(m,a[i],b); //cerr << temp << el; temp %= b; ans *= temp; ans %= b; } cout << ans << el; return; } void calc(void) { return; } int main(void) { cin.tie(nullptr); ios::sync_with_stdio(false); calc(); int t = 1; if (MULTI_TEST_CASE) cin >> t; while (t--) { solve(); } return 0; }