#include using namespace std; #include using namespace atcoder; using mint=modint998244353; //1000000007; using ll=long long; using pp=pair; #define sr string #define vc vector #define db double #define fi first #define se second #define rep(i,n) for(int i=0;i<(int)n;i++) #define pb push_back #define all(v) v.begin(),v.end() #define pque priority_queue #define bpc(a) __builtin_popcount(a) int main(){ int n,m,a,b;cin>>n>>m>>a>>b; vcban(m); rep(i,m)cin>>ban[i]; vcd; for(int i=1;i*i<=n;i++)if(n%i==0){ d.pb(i); if(i!=n/i)d.pb(n/i); } int k=d.size(); sort(all(d)); vc v(k,vc(0)); rep(i,k){ int b=n; rep(j,m)if(ban[j]%d[i]==0)b=min(b,ban[j]); for(int j=i+1;j=b)break; v[i].pb(j); } } pque,greater>q; vcdist(k,1e18); dist[0]=0; q.push({0,0}); while(q.size()){ auto [di,x]=q.top(); q.pop(); if(dist[x]