#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fast std::ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define clr0(a) memset((a), 0, sizeof(a))
#define clr1(a) memset((a), -1, sizeof(a))
#define srtin1 cin.ignore ( std::numeric_limits<std::streamsize>::max(), '\n' );
#define strin2 getline(cin, text);
#define ll long long
#define test cout<<"archit\n"
#define debug(x) cout<<x<<" "
#define debug1(x) cout<<x<<"\n"
#define debug2(x,y) cout<<x<<" "<<y<<"\n"
#define debug3(x, y, z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define pb push_back
#define pi pair<int,int>
#define fi first
#define si second
#define mod (ll)1000000007
#define mxn 1000005
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
//using namespace boost::multiprecision;
using namespace __gnu_pbds;
typedef struct node
{
    int val,wt;
}node;
int dp[1005][1005];
int solve(node* arr, int n, int weight)
{
    memset(dp, 0, sizeof(dp));
    for(int i=0;i<=weight;i++){
        dp[0][i] = INT_MAX;
    }
    for(int i=0;i<=n;i++){
        dp[i][0] = 0;
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=weight;j++){
            dp[i][j] = dp[i-1][j];
            if(arr[i-1].val == -1){
                continue;
            }
            if(arr[i-1].wt<=j){
                if(dp[i][j - arr[i-1].wt]!=INT_MAX)
                    dp[i][j] = min(dp[i][j], arr[i-1].val + dp[i][j - arr[i-1].wt]);
            }
        }
    }
    return dp[n][weight];
}
int main()
{
    fast;
    int n,w;
    cin>>n>>w;
    node* arr = new node[n];
    for(int i=1;i<=n;i++){
        int p; cin>>p;
        arr[i-1].wt = i;
        arr[i-1].val = p;
    }
    int ans = solve(arr, n, w);
    if(ans == INT_MAX){
        ans = -1;
    }
    debug(ans);
    return 0;
}
