#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,mod,k,ans=0,a[5000005],pre[5000005],nxt[5000005];
const int SIZE=1<<14;
char getc(){
static char buf[SIZE],*begin=buf,*end=buf;
if(begin==end){
begin=buf;
end=buf+fread(buf,1,SIZE,stdin);
}
return *begin++;
}
ll read()
{
ll x=0,f=1;
char ch=getc();
while(ch<'0'||ch>'9')
{
if(ch=='-')
f=-1;
ch=getc();
}
while(ch>='0' && ch<='9')
x=x*10+ch-'0',ch=getc();
return x*f;
}
void write(ll x) {
static int sta[35];
int top=0;
do{
sta[top++]=x%10,x/=10;
}while(x);
while(top) putchar(sta[--top]+48);
}
ll qpow(ll x,ll y,ll M){
ll Ans=1;
while(y){
if(y%2==1){
Ans=Ans*x%M;
}
x=x*x%M;
y/=2;
}
return Ans;
}
ll inv(ll x){
if(x==1)return 1;
return (mod-mod/x)*inv(mod%x)%mod;
}
int main(){
n=read();mod=read();k=read();
pre[0]=1;
nxt[n+1]=1;
for(int i=1;i<=n;i++){
a[i]=read();
pre[i]=(pre[i-1]%mod)*(a[i]%mod)%mod;
}
for(int i=n;i>=1;i--){
nxt[i]=(nxt[i+1]%mod)*(a[i]%mod)%mod;
}
ll K=k;
for(int i=1;i<=n;i++){
ans=(ans+(K*((pre[i-1]*nxt[i+1])%mod))%mod)%mod;
K=(K%mod)*(k%mod)%mod;
}
ans=(ans%mod)*(inv(pre[n]))%mod;
write(ans);
return 0;
}