#include<bits/stdc++.h>
using namespace std;
#define int long long
#define md(a) a=(a%mod+mod)%mod
#define file(a) freopen(#a".in","r",stdin);freopen(#a".out","w",stdout)
bool ST;
const int N=500005;
int n,S,Type,Tid,B,a[N],Ans[N];
int f[N],g[N][2],pos[2],q[710][2],gcd[710][710];vector<int>inc[710];
inline int lcm(int x,int y){if(x>y)swap(x,y);if(x<=B)return x*y/gcd[x][y%x];return x*y/__gcd(x,y);}
inline int w(int x,int y){int d=lcm(x,y);return (S/d)*d;}
inline void New(int j,int i,int v)
{
f[i]=max(f[i],f[j]+v);
}
bool ED;
signed main()
{
// int time_st=clock();
cerr<<(&ST-&ED)/1024.0/1024<<endl;ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>n>>S>>Type>>Tid;assert(Type==0);B=sqrt(S);for(int i=1;i<=n;i++)cin>>a[i];
for(int i=0;i<=B;i++)for(int j=0;j<=B;j++)if(i||j)gcd[i][j]=__gcd(i,j);
for(int i=n;i>=1;i--)if(a[i]<=B)inc[a[i]].push_back(i);int mx=1;
for(int i=1;i<=n;i++)
{
f[i]=max(f[i],f[i-1]);while(mx<i-1&&f[mx]+S<=f[i])mx++;
if(i-mx<=100){for(int j=mx;j<i;j++)f[i]=max(f[i],f[j]+w(a[j],a[i]));}
else
{
for(int t=0;t<2;t++)if(pos[t])New(pos[t],i,w(a[pos[t]],a[i]));
for(int j=1;j<=B;j++)for(int t=0;t<2;t++)if(q[j][t])New(q[j][t],i,w(j,a[i]));
if(a[i]>B){for(int j=a[i];j<=S;j+=a[i])for(int t=0;t<2;t++)if(g[j][t])New(g[j][t],i,j);}
}
if(a[i]<=B)pos[0]=pos[1],pos[1]=i,q[a[i]][0]=q[a[i]][1],q[a[i]][1]=i;
else
{
for(int j=a[i];j<=S;j+=a[i])g[j][0]=g[j][1],g[j][1]=i;
for(int j=1;j<=B;j++)
{
while(!inc[j].empty()&&inc[j].back()<=i)inc[j].pop_back();int s=inc[j].size();
if(s>=1)New(i,inc[j][s-1],w(j,a[i]));if(s>=2)New(i,inc[j][s-2],w(j,a[i]));
}
}
}
cout<<f[n]<<'\n';
// cerr<<(clock()-time_st)/1e6<<endl;return 0;
}