n, k = map(int, input().split())
v = list(map(int, input().split()))
vv = [0] * (n + 1)
for i in range(n):
    vv[i + 1] = vv[i] + v[i]
sumv = vv[n]
ans = 0
for l in range(n):
    for r in range(l - 1, n):
        c = r - l + 1
        if n - c > k:
            continue
        x = []
        value = sumv - (vv[r + 1] - vv[l])
        for i in range(n):
            if not l <= i <= r:
                x.append(v[i])
        x.sort()
        for i in range(max(0, min(k - (n - c), len(x)))):
            if x[i] < 0:
                value -= x[i]
            else:
                break
        ans = max(value, ans)
print(ans) n, k = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split k v = list(map(int, input().split())) v list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split vv = [0] * (n + 1) vv [0] * (n + 1) [0] 0 n + 1 n 1 for i in range(n):
    vv[i + 1] = vv[i] + v[i] i range(n) range n vv[i + 1] = vv[i] + v[i] vv[i + 1] vv i + 1 i 1 vv[i] + v[i] vv[i] vv i v[i] v i sumv = vv[n] sumv vv[n] vv n ans = 0 ans 0 for l in range(n):
    for r in range(l - 1, n):
        c = r - l + 1
        if n - c > k:
            continue
        x = []
        value = sumv - (vv[r + 1] - vv[l])
        for i in range(n):
            if not l <= i <= r:
                x.append(v[i])
        x.sort()
        for i in range(max(0, min(k - (n - c), len(x)))):
            if x[i] < 0:
                value -= x[i]
            else:
                break
        ans = max(value, ans) l range(n) range n for r in range(l - 1, n):
        c = r - l + 1
        if n - c > k:
            continue
        x = []
        value = sumv - (vv[r + 1] - vv[l])
        for i in range(n):
            if not l <= i <= r:
                x.append(v[i])
        x.sort()
        for i in range(max(0, min(k - (n - c), len(x)))):
            if x[i] < 0:
                value -= x[i]
            else:
                break
        ans = max(value, ans) r range(l - 1, n) range l - 1 l 1 n c = r - l + 1 c r - l + 1 r - l r l 1 if n - c > k:
            continue
         n - c > k n - c n c k continue x = [] x [] value = sumv - (vv[r + 1] - vv[l]) value sumv - (vv[r + 1] - vv[l]) sumv vv[r + 1] - vv[l] vv[r + 1] vv r + 1 r 1 vv[l] vv l for i in range(n):
            if not l <= i <= r:
                x.append(v[i])
         i range(n) range n if not l <= i <= r:
                x.append(v[i])
         not l <= i <= r l <= i <= r l <= i l i r x.append(v[i]) x.append x append v[i] v i x.sort() x.sort x sort for i in range(max(0, min(k - (n - c), len(x)))):
            if x[i] < 0:
                value -= x[i]
            else:
                break
         i range(max(0, min(k - (n - c), len(x)))) range max(0, min(k - (n - c), len(x))) max 0 min(k - (n - c), len(x)) min k - (n - c) k n - c n c len(x) len x if x[i] < 0:
                value -= x[i]
            else:
                break
         x[i] < 0 x[i] x i 0 value -= x[i] value x[i] x i break ans = max(value, ans) ans max(value, ans) max value ans print(ans) print ans x = [] [] x value = sumv - (vv[r + 1] - vv[l]) sumv - (vv[r + 1] - vv[l]) value ans = max(value, ans) max(value, ans) ans ans = 0 0 ans value -= x[i] x[i] value n, k = map(int, input().split()) map(int, input().split()) n vv = [0] * (n + 1) [0] * (n + 1) vv v = list(map(int, input().split())) list(map(int, input().split())) v k = map(int, input().split()) map(int, input().split()) k sumv = vv[n] vv[n] sumv c = r - l + 1 r - l + 1 c
n, k = map(int, input().split())
v = list(map(int, input().split()))
vv = [0] * (n + 1)
for i in range(n):
    vv[i + 1] = vv[i] + v[i]
sumv = vv[n]
ans = 0
for l in range(n):
    for r in range(l - 1, n):
        c = r - l + 1
        if n - c > k:
            continue
        x = []
        value = sumv - (vv[r + 1] - vv[l])
        for i in range(n):
            if not l <= i <= r:
                x.append(v[i])
        x.sort()
        for i in range(max(0, min(k - (n - c), len(x)))):
            if x[i] < 0:
                value -= x[i]
            else:
                break
        ans = max(value, ans)
print(ans)