#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
//#include <atcoder/all>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int main(){
  int N; cin >> N;
  ll X; cin >> X;
  vector<ll> A(N); rep(i,N) cin >> A[i];
  reverse(all(A));
  //rep(i,N) cout << A[i] << " ";
  //cout << endl;
  vector<map<ll,ll>> dp(N+1);
  dp[0][X]=1;
  for(int i=1;i<=N;i++){
    for(auto m:dp[i-1]){
      ll x = m.first;
      //cout << i <<" " << x << " " << m.second << endl;
      if(x>=0){
        ll t = (x)/A[i-1];
        //cout << t << endl;
        if(!(i>1&&t>=A[i-2]/A[i-1])){
          if(abs(x-A[i-1]*t)<A[i-1]){
            dp[i][x-A[i-1]*t]+=m.second;
          }
        }
        if(!(i>1&&t+1>=A[i-2]/A[i-1])){
          if(abs(x-A[i-1]*(t+1))<A[i-1]){
            dp[i][x-A[i-1]*(t+1)]+=m.second;
          }
        }
      }
      else{
        ll t=(-x)/A[i-1];
        //cout << t << endl;
        if(!(i>1&&t>=A[i-2]/A[i-1])){
          if(abs(x+A[i-1]*t)<A[i-1]){
            dp[i][x+A[i-1]*t]+=m.second;
          }
        }

        if(!(i>1&&t+1>=A[i-2]/A[i-1])){
          if(abs(x+A[i-1]*(t+1))<A[i-1]){
            dp[i][x+A[i-1]*(t+1)]+=m.second;
          }
        }
      }
    }
  }
  cout << dp[N][0] << endl;;
  return 0;
}

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
using Graph = vector<vector<int>>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int main(int argc, const char * argv[]) {
    ios::sync_with_stdio(false);

    int n;
    cin>>n;
    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    ll ans=0;
    ll sum=0;
    vector<ll>b(n+1);
    b[0]=0;
    for(int i=1;i<n+1;i++){
        b[i]=b[i-1]+a[i-1];
    }
    int max_point=0;
    for(int i=0;i<n;i++){
        chmax(ans,sum+b[max_point]);
        if(sum+b[max_point]<sum+b[i+1]){
            max_point=i+1;
        }
        sum+=b[i+1];
    }
    chmax(ans,sum);
    cout<<ans<<endl;

    return 0;
}