import itertools import sys import fractions input = sys.stdin.readline def main(): N, V = map(int, input().split()) *C, = itertools.accumulate(map(int, input().split())) V -= N if V <= 0: print(C[-1]) return L = (N**3-N)//2 DP = [0] + [float('inf')]*L for i in range(1, L+1): for j in range(N): if i > j: DP[i] = min(DP[i], DP[i-(j+1)]+C[j]) if V <= L: print(C[-1] + DP[V]) else: target = min(range(N), key=lambda i: fractions.Fraction(C[i], i+1)) greedy = (V-(L+1))//(target+1) + 1 print(C[-1] + greedy*C[target] + DP[V-(target+1)*greedy]) if __name__ == '__main__': main()