[latexpage]

### 注意到，f[i] 的递推方式很像斐波那契数列，所以我们可以利用矩阵乘法来求 f[i]

\label{eq:poly}
\begin{Bmatrix}
f(i) \\
f(i+1)
\end{Bmatrix}=
\begin{Bmatrix}
f(i+1) \\
f(i+2)
\end{Bmatrix}*
\begin{Bmatrix}
p & 1-p \\
1 & 0
\end{Bmatrix}

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#define MX 12
using namespace std;
double p;
int bom[MX],n;
void input(){
for(int i=1;i<=n;i++)scanf("%d",&bom[i]);
sort(bom+1,bom+n+1);
}
void mul(double dist[][3],double a[][3],double b[][3]){
double now[3][3];
for(int i=1;i<=2;i++)for(int j=1;j<=2;j++)now[i][j]=0;
for(int i=1;i<=2;i++)for(int j=1;j<=2;j++)for(int k=1;k<=2;k++)now[i][j]+=a[k][j]*b[i][k];
for(int i=1;i<=2;i++)for(int j=1;j<=2;j++)dist[i][j]=now[i][j];
}
void quickp(double dist[][3],double src[][3],int t){
double ans[3][3],now[3][3];
for(int i=1;i<=2;i++)for(int j=1;j<=2;j++)now[i][j]=src[i][j];
ans[1][1]=ans[2][2]=1,ans[2][1]=ans[1][2]=0;
while(t>=1){
if(t%2==1)mul(ans,now,ans);
mul(now,now,now);
t/=2;
}
for(int i=1;i<=2;i++)for(int j=1;j<=2;j++)dist[i][j]=ans[i][j];
}
double work(int len){
if(len==0)return 0;
double sc[3][3],f[3][3];
sc[1][1]=p,sc[1][2]=1-p,sc[2][1]=1,sc[2][2]=0,f[1][1]=1-p,f[1][2]=0,f[2][1]=0,f[2][2]=0;
quickp(sc,sc,len-1);
mul(f,f,sc);
return f[1][1];
}
int main(){
double ans;
while(cin>>n>>p,ans=1){
input();
for(int i=1;i<=n;i++)if(bom[i]!=bom[i-1])ans*=(work(bom[i]-bom[i-1]-1));
printf("%.7f\n",ans);
}
return 0;
}