#include using namespace std; #undef _P #define _P(...) (void)printf(__VA_ARGS__) #define FORR(x,arr) for(auto&& x:arr) #define FOR(i,a,b) for (int i = (a); i < (b); i++) #define RFOR(i,a,b) for (int i = (b)-1; i >= (a); i--) #define REP(i,n) for (int i = 0; i < (n); i++) #define RREP(i,n) for (int i = (n)-1; i >= 0; i--) #define ALL(x) (x).begin(), (x).end() #define BIT(n) (1LL<<(n)) #define SZ(x) ((int)(x).size()) typedef long long ll; // ------------------------------------- template inline bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } typedef pair DI; int N, V; ll C[100]; void Main() { scanf("%d %d", &N, &V); vector v_ci(N); REP(i, N) { scanf("%lld", C+i); if (i) C[i] += C[i-1]; v_ci[i] = {1.0 * C[i] / (i+1), i}; } ll ans = C[N-1]; V -= N; if (V <= 0) { _P("%lld\n", ans); return; } sort(ALL(v_ci)); int mi = v_ci[0].second; int mv = mi + 1; int x = V / mv; if (x > 10) { V -= (x - 10) * mv; ans += (x - 10) * C[mi]; } vector dp(V+1, 1e18 + 1); dp[0] = ans; REP(i, V) if (dp[i] > 0) { REP(j, N) if (i+j+1 <= V) { amin(dp[i + j + 1], dp[i] + C[j]); } } _P("%lld\n", dp[V]); } int main() { cin.tie(0); ios::sync_with_stdio(false); Main(); return 0; }