#include using namespace std; #define REP(i,a,b) for(i=a;i sum[i] * opt) opt = i; } res = 0; k = max(0, (VV-11111) / opt); res += k * sum[opt]; VV -= k * opt; while(VV >= 11111) VV -= opt, res += sum[opt]; res += dp[VV]; res += sum[N]; return res; } int main(){ int i, j, k; ll res; N = read_int(1, N_MAX, ' '); V = read_int(1, V_MAX, '\n'); rep(i,N) C[i] = read_int(1, C_MAX, i==N-1?'\n':' '); if(V > N){ res = solve(); } else { res = 0; rep(i,N) res += C[i]; } printf("%lld\n",res); {char c; assert(scanf("%c",&c)!=1);} return 0; }