#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define all(a) a.begin(), a.end()
#define ff(i,a,b) for(int i=a;i<=b;i++)
#define fb(i,b,a) for(int i=b;i>=a;i--)

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 200005;
const int inf = 1e9 + 5;

int n;
ll niz[maxn];

ll pref[maxn];
ll mx[maxn];

int main()
{
   ios::sync_with_stdio(false);
   cout.tie(nullptr);
   cin.tie(nullptr);
   cin >> n;
   ff(i,1,n)cin >> niz[i];
   ff(i,1,n){
      pref[i] = pref[i - 1] + niz[i];
      mx[i] = max(mx[i - 1], pref[i]);
   }
   ll najv = 0;
   ll pre = 0;
   ff(i,1,n){
      ll ima = pre + mx[i];
      najv = max(najv, ima);
      pre = pref[i] + pre;
   }
   cout << najv << endl;
   return 0;
}
/**

**/


#include <bits/stdc++.h>

using namespace std ;

#define i64 int64_t // typecast using i64(x)
#define int int64_t 
#define ld long double
#define endl "\n"
#define f(i,a,b) for(int i=int(a);i<int(b);++i)

#define pr pair
#define ar array
#define fr first
#define sc second
#define vt vector
#define pb push_back
#define LB lower_bound  
#define UB upper_bound
#define PQ priority_queue

#define sz(x) ((int)(x).size())
#define all(a) (a).begin(),(a).end()
#define allr(a) (a).rbegin(),(a).rend()
#define mem0(a) memset(a, 0, sizeof(a))
#define mem1(a) memset(a, -1, sizeof(a))

// Input functions
// Use only for reading int, vectors, strings.
// Be careful that it reads the complete vector.
template<class A> void rd(vt<A>& v);
template<class T> void rd(T& x){ cin >> x; }
template<class H, class... T> void rd(H& h, T&... t) { rd(h) ; rd(t...) ;}
template<class A> void rd(vt<A>& x) { for(auto& a : x) rd(a) ;}

// DEBUG functions
template<typename T>
void __p(T a) {
  cout<<a; 
}
template<typename T, typename F>
void __p(pair<T, F> a) {
  cout<<"{";
  __p(a.first);
  cout<<",";
  __p(a.second);
  cout<<"}\n"; 
}
template<typename T>
void __p(std::vector<T> a) {
  cout<<"{";
  for(auto it=a.begin(); it<a.end(); it++)
    __p(*it),cout<<",}\n"[it+1==a.end()]; 
}
template<typename T, typename ...Arg>
void __p(T a1, Arg ...a) {
  __p(a1);
  __p(a...);
}
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
  cout<<name<<" : ";
  __p(arg1);
  cout<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
  int bracket=0,i=0;
  for(;; i++)
    if(names[i]==','&&bracket==0)
      break;
    else if(names[i]=='(')
      bracket++;
    else if(names[i]==')')
      bracket--;
  const char *comma=names+i;
  cout.write(names,comma-names)<<" : ";
  __p(arg1);
  cout<<" | ";
  __f(comma+1,args...);
}

//Fast input output
void setIO(string s = "") {
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
  cin.exceptions(cin.failbit); 
  if(sz(s)){
    freopen((s+".in").c_str(),"r",stdin);
    freopen((s+".out").c_str(),"w",stdout);
  }
}
void chmax(int &x,int y){x = max(x,y) ; return ;}
signed main(){
  setIO() ;
	int N, X; rd(N,X);
	vt<int> a(N+1); 
	f(i,1,N+1) rd(a[i]) ;
	
	int ans = 1e18 ;
	const int _ = 105;
	int dp[_][_][_] ;
	//fixing remainder which is same as number of members here
	for(int count = 1; count <= N; count++){
		
		
		mem1(dp) ;
		
		dp[0][0][0] =  0 ;
		for(int i=0; i<N; i++){
			
			for(int j=0; j<=count; j++){
				for(int k=0; k<count; k++){
					chmax(dp[i+1][j][k],dp[i][j][k]) ;
				}
			}
		
			for(int j=0; j<=count; j++){
				for(int k=0; k<count; k++){
					if(dp[i][j][k] != -1){
						chmax(dp[i+1][j+1][(dp[i][j][k]+a[i+1])%count],dp[i][j][k] + a[i+1]) ;
					}
				}
			}
		
		}
	
		int res = X%count ;
		if(dp[N][count][res] != -1){
			int temp = X - dp[N][count][res];
			ans = min(ans, temp/count);
		}
	}
	
	cout << ans ;
}









