#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i,N)
        cin >> A[i];
    ll DP[N+1][2];
    ll numm[N+1]={0},nump[N+1]={0};
    memset(DP,0,sizeof(DP));
    DP[1][0] = A[0];
    nump[1] = 1;
    numm[1] = 0;
    for(int i=2;i<=N;i++){
        nump[i] = nump[i-1] + numm[i-1];
        numm[i] = nump[i-1];
        nump[i] %= MOD;
        numm[i] %= MOD;
        DP[i][0] = nump[i]*A[i-1];
        DP[i][0] %=MOD;
        DP[i][0] += DP[i-1][0] + DP[i-1][1];
        DP[i][0] %=MOD;
        DP[i][1] = DP[i-1][0] - numm[i]*A[i-1];
        if(i != N){
            while(DP[i][1] < 0)
                DP[i][1] += (ll)MOD*(ll)MOD;
        }
        DP[i][1] %=MOD;
    }

    ll ans = DP[N][0] + DP[N][1];
    while(ans < 0)
        ans += (ll)MOD * (ll)(MOD);
    ans %= MOD;
    cout << ans << endl;
}

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pb push_back
#define ff first
#define ss second
#define YES cout << "YES\n"
#define NO cout << "NO\n"
#define nn "\n"
#define sci(x) scanf("%d", &x)
#define LL_INF (1LL << 62)
#define INF (1 << 30)
#define SetBit(x, k) (x |= (1LL << k))
#define ClearBit(x, k) (x &= ~(1LL << k))
#define CheckBit(x, k) (x & (1LL << k))
#define mod 998244353
#define N 200005

int n;
ll z;
int x[105];
int dp[105][105][105];

int solve(int pos, int cnt, int rem, int k){
    if(cnt==k){
        if(rem==0) return 0;
        return -INF;
    }
    if(pos>=n) return -INF;

    if(dp[pos][cnt][rem]!=-1) return dp[pos][cnt][rem];

    int res = -INF;
  res = max(res, x[pos]+solve(pos+1, cnt+1, (k+(rem-x[pos])%k)%k, k));
    res = max(res, solve(pos+1, cnt, rem, k));
    

    return dp[pos][cnt][rem] = res;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> n >> z;
    for(int i = 0; i < n; i++){
        cin >> x[i];
    }

    ll res = LL_INF;
    for(int i = 1; i <= n; i++){
        memset(dp, -1, sizeof dp);
        ll r = solve(0, 0, z%i, i);
        if(r>=0 && (z-r)%i==0) res = min(res, (z-r)/i);
    }

    cout << res << nn;
    
    return 0;
}