#include<cstdio>
using namespace std;
typedef long long ll;
const int N=5e6+10;
ll n,k,a[N],p,t=1,ans,suf[N],inv=1,sum[N];
inline ll read(){
ll x=0,f=1;
char ch;
ch=getchar();
while(ch<'0'&&ch>'9'){
if(ch=='-') f=-1;
ch=getchar();
}
while(ch>='0'&&ch<='9'){
x=x*10+ch-'0';
ch=getchar();
}
return x*f;
}
inline void write(ll x){
if(x<0){
putchar('-');
x=-x;
}
if(x>9) write(x/10);
putchar(x%10+'0');
return ;
}
inline ll qpow(ll x){
ll ypy=p-2,res=1;
while(ypy){
if(ypy&1) res=(res*x)%p;
x=(x*x)%p;
ypy=ypy>>1;
}
return res%p;
}
int main(){
n=read(),p=read(),k=read();
for(int i=1;i<=n;++i){
a[i]=read();
inv=(inv*a[i])%p;
}
inv=qpow(inv)%p;
sum[1]=1;
for(int i=2;i<=n;++i){
sum[i]=(sum[i-1]*a[i-1])%p;
}
suf[n]=1;
for(int i=n-1;i>=1;--i){
suf[i]=(a[i+1]*suf[i+1])%p;
}
for(int i=1;i<=n;++i){
t=(t*k)%p;
ans=(ans%p+sum[i]%p*suf[i]%p*t%p)%p;
}
ans=ans*inv%p;
write(ans%p);
return 0;
}