#include <cctype>
#include <cstdint>
#include <cstdio>
#include <iostream>
#include <tuple>

using ll = int64_t;

std::tuple<ll,ll,ll> exgcd(ll a,ll b){
    if(b==0){
        ll x=1,y=0;
        return std::make_tuple(a,x,y);
    }
    auto [d,x,y] = exgcd(b,a%b);
    ll tmpy=y;
    y=x-a/b*y;
    x=tmpy;
    return std::make_tuple(d,x,y);
}

ll inv(ll n,ll p){
    auto[a,x,y] = exgcd(n, p);
    x=(x%p+p)%p;
    return x;
}

struct ReadNum{
    char c;
    ll w;
    ReadNum&operator>>(ll&n){
        c=n=0,w=1;
        while(!isdigit(c)){
            if(c=='-'){
                w = -1;
            }
            c = getchar();
        }
        while(isdigit(c)){
            n=n*10+(c-'0');
            c=getchar();
        }
        n=n*w;
        return *this;
    }
}readint;

int main(){
    ll n,p,k,ans{},ai,a{1};
    readint>>n>>p>>k;
    ll kp{1};
    for(ll i{1};i<=n;i++){
        kp=(kp*k)%p;
    }
    for(ll i{1};i<=n;i++){
        readint>>ai;
        a=(a*ai)%p;
    }
    ans=(kp*inv(a,p))%p;
    std::cout<<ans<<'\n';
}