/* ` `` ` . ` .g,` Welcome To My Coding Space! .MMe `(F(#~ `.J, `.M/7b. dD.N; (#=#: `` db (m.#` Wl(@ jF ` `` ` ` ` ..+kMMN;_(Y> `(TD d$..gHN_ ` `` ...... ` ` ` `..gMB61+1+dK `- `. .TM@^(d% `` `` ..JggHHMMHHYYTHMMMNmgJ.. .kB6z?1+z1+
+H8+=??=?=?=???=?=?=z1&z1?==?1dMdNcHmJ1+1JMMR1?z??Ne1dM9+?(MF(MI+jMf .`.``.`.. (TNaHr`.`.TNmN:(MR+?zMK(M$` `.`.``dF ` J#<=1;?Wp .``.` J#>dN, ..``.`dF` `_UmMn .`..`..`..`. JMYT1<;;;>>>>>;>>?Wo ..`. dK1=dN,`..``.MN+ .dMMe .`.``.`.`.` d#<;>>>>;>>>>;>>>>(N,`.. -MK1llvWm. JM?Mp. ` ` ` .M9+?Me`.`..`.`.`` JN(>;>>;>>;>>>;>>>>>>>;>>>>>;>>>>>>>>>>>>>>><(W$(M8TIllllllllllllllllzvMo ` ` ` (#1?==1?===z?TNa,.` `` (Ne<<>>>>><;><;jgMMY1HK1lllllllllllllllllllJMp ` .Ne&g&x1=?=?==?1zTHNmJ-...dNgJ++++&ggMH9=~ .M9Izlllllllllllllllllll1WF ` ` _???MK<=??=??1z?(MM@!d#M#Y""""= #define rep(i,a,b) for(int i=a;i=b;i--) #define INF 1LL<<60 int N; ll V, C[101], sm[101], dp[30202]; //--------------------------------------------------------------------------------------------------- void _main() { cin >> N >> V; rep(i, 0, N) cin >> C[i]; sm[0] = 0; rep(i, 0, N) sm[i + 1] = sm[i] + C[i]; if (V <= N) { cout << sm[N] << endl; return; } V -= N; int opt = 1; rep(i, 2, N + 1) if (sm[i] * opt < sm[opt] * i) opt = i; rep(i, 0, min(20202, (int)V) + 1) { dp[i] = INF; if ((V - i) % opt == 0) dp[i] = (V - i) / opt * sm[opt]; } rrep(i, min(20202, (int)V), 0) { rep(j, 1, N + 1) dp[i] = min(dp[i], dp[i + j] + sm[j]); } cout << dp[0] + sm[N] << endl; }