// Created by ash_98
 
#include<bits/stdc++.h>
using namespace std;
 
#define mx 3005
#define ll long long
#define mod 1000000007
 
ll ar[mx];
char ch[mx];
int n,m,ii,k;
vector<pair<int,int>>g[mx];
int add(int a,int b)
{
   a+=b;
   if(a>=mod)a-=mod;
   return a;
}
int dp[mx][mx];
bool vis[mx][mx];
ll pre[mx];

void solve()
{
   scanf("%d",&n);
   for(int i=1;i<=n;i++)scanf("%lld",&ar[i]),pre[i]=pre[i-1]+ar[i];
   dp[1][0]++;
   int re=0;
   for(int i=1;i<=n;i++)
   {
      
      for(int j=n;j>=1;j--)
      {
         dp[j+1][pre[i]%(j+1)]=add(dp[j+1][pre[i]%(j+1)],dp[j][pre[i]%j]);
         if(i==n)
         {
            re=add(re,dp[j][pre[i]%j]);
         }
      }
     
   }
   printf("%d\n",re);



}
 
int main()
{
   int t=1;
   //scanf("%d",&t);
   while(t--)solve();
   return 0;
}
#include <bits/stdc++.h>
using namespace std;

int n, t;


void bit(vector<int> v, vector<int> &s) {
    int l = v.size();
    for (int mask = 0; mask < (1 << l); mask++) {
        int sum = 0;
        for (int i = 0; i < l; i++) {
            if (mask & (1 << i)) sum += v[i];
            if (sum > t)
            	goto end;
        }
        s.push_back(sum);
        end:;
    }
}
 
int main() {
    cin >> n >> t;
    vector<int> A, B;
    for (int i = 0, a; i < n; i++) {
        cin >> a;
        if (i % 2) A.push_back(a);
        else B.push_back(a);
    }
 
    vector<int> C, D;
    bit(A, C);
    bit(B, D);
    sort(C.begin(), C.end());
    sort(D.begin(), D.end());
 
    int ans = 0;
    for (int a : C)
        ans = max(ans, a + (*--upper_bound(D.begin(), D.end(), t - a)));
 
    cout << ans << endl;
}