//2021-04-18 12:10:11
/*折半枚舉*/
#include <bits/stdc++.h>
using namespace std;

int n,a[100],id[2];
long long t;
vector<long long>re[2];//re[0]是小的那部分枚舉出來的東東，re[1]是大的那部分枚舉出來的東東

bool d[100]={0};


int target,from;//紀錄正在枚舉的頭和尾
bool big=false;//現在是否在枚舉大的
void f(int id){
    if(id==target){
        long long ans=0;
        for(int i=from;i<target;i++)ans+=d[i]*a[i];
        re[big].emplace_back(ans);
        return;}
    f(id+1);
    d[id]=1;
    f(id+1);
    d[id]=0;
return;}


int main(){
    //輸入
    scanf("%d %lld",&n,&t);
    for(int i=0;i<n;i++)scanf("%d",&a[i]);
    sort(a,a+n);
    
    //枚舉小堆的
    from=0,target=(n+1)/2;
    f(0);
    //枚舉大堆的
    from=target,target=n,big=true;
    f(from);
    
    //整理枚舉出來的東東
    sort(re[0].begin(),re[0].end());
    sort(re[1].begin(),re[1].end());

    //雙指針求解
    long long ans=0;
    int l1=re[0].size(),l2=re[1].size(),j=0;
    for(int i=0;i<l1;i++){   
        if(re[0][i]>t)break;
        ans=max(re[0][i],ans);
        
        while(j<l2-1&&(re[1][j]+re[0][i])<t)j++;
        while(j>=0&&(re[1][j]+re[0][i])>t)j--;
        if(j>=0&&(re[1][j]+re[0][i])<=t)ans=max(re[0][i]+re[1][j],ans);
        if(ans==t)break;}
    printf("%lld\n",ans);
return 0;}
#include<cstdio>
#include<algorithm>
#define Q 200005
using namespace std;
#define gc() getchar()
inline bool ig(char c){return c>='0'&&c<='9';}
inline void read(int &oi){char c;int f=1,res=0;while(c=gc(),(!ig(c))&&c^'-');c^'-'?res=(c^48):f=-1;while(c=gc(),ig(c))res=res*10+(c^48);oi=f*res;}
inline void print(int oi){if(oi<0)putchar('-'),oi=~oi+1;if(oi>9)print(oi/10);putchar(oi%10+48);}
int l,r,ans;
inline int gcd(int x,int y){return !y?x:gcd(y,x%y);}
inline int maxx(int x,int y){return x>y?x:y;}
inline void solve(int tim){
	for(int i=2;i*i<=tim;++i){
		if(tim%i)continue;
		if(tim-(tim/i)>=l)ans=maxx(ans,tim/i);
		if(tim-i>=l)ans=maxx(ans,i);
	}
}
int main(){
	read(l);read(r);ans=gcd(l,l+1);
	for(int i=l+2;i<=r;++i)solve(i);print(ans);putchar('\n');
	return 0;
}