1 10
1
 10 1
-1 1 1 1 1 1 1 1 1 1
 78 8
-230 -757 673 -284 381 -324 -96 975 249 971 -355 186 -526 804 147 -553 655 263 -247 775 108 -246 -107 25 -786 -372 -24 -619 265 -192 269 392 210 449 335 -207 371 562 307 141 668 78 13 251 623 -238 60 543 618 201 73 -35 -663 620 485 444 330 362 -33 484 685 257 542 375 -952 48 -604 -288 -19 -718 -798 946 -533 -666 -686 -278 368 -294
 82 8
-483 465 435 -789 80 -412 672 512 -755 981 784 -281 -634 -270 806 887 -495 -46 -244 609 42 -821 100 -40 -299 -6 560 941 523 758 -730 -930 91 -138 -299 0 533 -208 -416 869 967 -871 573 165 -279 298 934 -236 70 800 550 433 139 147 139 -212 137 -933 -863 876 -622 193 -121 -944 983 -592 -40 -712 891 985 16 580 -845 -903 -986 952 -95 -613 -2 -45 -86 -206
 6 9
-669 45 -220 544 106 680
 116 10
477 -765 -756 376 -48 -75 768 -658 263 -207 362 -535 96 -960 630 -686 609 -830 889 57 -239 346 -298 -18 -107 853 -607 -443 -517 371 657 105 479 498 -47 432 503 -917 -656 610 -466 216 -747 -587 -163 -174 493 -882 853 -582 -774 -477 -386 610 -58 557 968 196 69 610 -38 366 -79 574 170 317 332 189 158 -194 136 -151 500 309 624 316 543 472 132 -15 -78 166 360 -71 12 247 678 263 573 -198 1 101 155 -65 597 -93 60 3 -496 985 -586 -761 -532 506 578 -13 569 845 -341 870 -900 891 724 408 229 -210
 32 9
-650 -208 506 812 -540 -275 -272 -236 -96 197 425 475 81 570 281 633 449 396 401 -362 -379 667 717 875 658 114 294 100 286 112 -928 -373
 38 1
173 587 -788 163 83 -768 461 -527 350 3 -898 634 -217 -528 317 -238 545 93 -964 283 -798 -596 77 222 -370 -209 61 846 -831 -419 -366 -509 -356 -649 916 -391 981 -596
 9 9
-767 148 -323 -818 41 -228 615 885 -260
 24 5
-751 889 721 -900 903 -900 -693 895 828 314 836 -493 549 -74 264 662 229 517 -223 367 141 -99 -390 283
 18 1
166 788 276 -103 -491 195 -960 389 376 369 630 285 3 575 315 -987 820 466
 36 5
-286 762 -5 -230 -483 -140 -143 -82 -127 449 435 85 -262 567 454 -163 942 -679 -609 854 -533 717 -101 92 -767 795 -804 -953 -754 -251 -100 884 809 -358 469 -112
 11 7
877 -188 10 -175 217 -254 841 380 552 -607 228
 47 10
-175 246 -903 681 748 -338 333 0 666 245 370 402 -38 682 144 658 -10 313 295 351 -95 149 111 -210 645 -173 -276 690 593 697 259 698 421 584 -229 445 -215 -203 49 642 386 649 469 4 340 484 279
 1 10
-1
 1 1
1
 29 6
-21 486 -630 -433 -123 -387 618 110 -203 55 -123 524 -168 662 432 378 -155 -136 -162 811 457 -157 -215 861 -565 -506 557 348 -7
 1 1
-1
 94 2
432 255 304 757 -438 52 461 55 837 -564 304 713 -968 -539 -593 835 -824 -532 38 -880 -772 480 -755 -387 -830 286 -38 -202 -273 423 272 471 -224 306 490 532 -210 -245 -20 680 -236 404 -5 -188 387 582 -30 -800 276 -811 240 -4 214 -708 200 -785 -466 61 16 -742 647 -371 -851 -295 -552 480 38 924 403 704 -705 -972 677 569 450 446 816 396 -179 281 -564 -27 -272 -640 809 29 28 -209 -925 997 -268 133 265 161
 35 5
151 -160 -292 -31 -131 174 359 42 438 413 164 91 118 393 76 435 371 -76 145 605 292 578 623 405 664 330 455 329 66 168 179 -76 996 163 531
 110 4
-813 -73 334 667 602 -155 432 -133 689 397 461 499 630 40 69 299 697 449 -130 210 -146 415 292 123 12 -105 444 338 509 497 142 688 603 107 -108 160 211 -215 219 -144 637 -173 615 -210 521 545 377 -6 -187 354 647 309 139 309 155 -242 546 -231 -267 405 411 -271 -149 264 -169 -447 -749 -218 273 -798 -135 839 54 -764 279 -578 -641 -152 -881 241 174 31 525 621 -855 656 482 -197 -402 995 785 338 -733 293 606 294 -645 262 909 325 -246 -952 408 646 2 -567 -484 661 -390 -488

1
 9
 17941
 18704
 1375
 24624
 9049
 2743
 1689
 8398
 5016
 8222
 3105
 14728
 -1
 1
 6299
 -1
 7839
 9754
 20286

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.Scanner;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.util.InputMismatchException;

/**
 * Ashesh Vidyut (Drift King) *
 */
public class C {
    public static void main(String[] args) {
        try {
            InputReader in = new InputReader(System.in);
            int n = in.readInt();
            int k = in.readInt();
            int a[] = new int [n];
            for (int i = 0; i < n; i++) {
                a[i] = in.readInt();
            }
            int max = Integer.MIN_VALUE;
            for (int i = 0; i < n; i++) {
                for (int j = i; j < n; j++) {
                    max = Math.max(max, findMaxRange(a, i, j, k));
                }
            }
            System.out.println(max);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    public static int findMaxRange(int a[], int l, int r, int k){
        int ar[] = new int[a.length];
        for (int i = 0; i < a.length; i++) {
            ar[i] = a[i];
        }
        for (int i = 0; i < k; i++) {
            int maxoutside = Integer.MIN_VALUE;
            if(l - 1 >= 0){
                maxoutside = Math.max(maxoutside, findMax(ar, 0, l - 1));
            }
            if(r + 1 < a.length){
                maxoutside = Math.max(maxoutside, findMax(ar, r + 1, a.length - 1));
            }
            for (int j = l; j <= r; j++) {
                if(ar[j] < maxoutside){
                    ar[j] = maxoutside;
                    break;
                }
            }
        }
        int sum = 0;
        for (int i = l; i <= r; i++) {
            sum += ar[i];
        }
        return sum;
    }
    public static int findMin(int a[], int l, int r){
        int min = Integer.MAX_VALUE;
        for (int i = l; i <= r; i++) {
            min = Math.min(a[i], min);
        }
        return min;
    }
    public static int findMax(int a[], int l, int r){
        int max = Integer.MIN_VALUE;
        int mind = -1;
        for (int i = l; i <= r; i++) {
            if(max < a[i]){
                max = a[i];
                mind = i;
            }
        }
        a[mind] = -1;
        return max;
    }
}

class InputReader {
    private boolean finished = false;

    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;

    public InputReader(InputStream stream) {
        this.stream = stream;
    }

    public int read() {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    public int peek() {
        if (numChars == -1)
            return -1;
        if (curChar >= numChars) {
            curChar = 0;
            try {
                numChars = stream.read(buf);
            } catch (IOException e) {
                return -1;
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar];
    }

    public int readInt() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public long readLong() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        long res = 0;
        do {
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        } while (!isSpaceChar(c));
        return res * sgn;
    }

    public String readString() {
        int length = readInt();
        if (length < 0)
            return null;
        byte[] bytes = new byte[length];
        for (int i = 0; i < length; i++)
            bytes[i] = (byte) read();
        try {
            return new String(bytes, "UTF-8");
        } catch (UnsupportedEncodingException e) {
            return new String(bytes);
        }
    }

    public static boolean isSpaceChar(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    private String readLine0() {
        StringBuffer buf = new StringBuffer();
        int c = read();
        while (c != '\n' && c != -1) {
            if (c != '\r')
                buf.appendCodePoint(c);
            c = read();
        }
        return buf.toString();
    }

    public String readLine() {
        String s = readLine0();
        while (s.trim().length() == 0)
            s = readLine0();
        return s;
    }

    public String readLine(boolean ignoreEmptyLines) {
        if (ignoreEmptyLines)
            return readLine();
        else
            return readLine0();
    }

    public BigInteger readBigInteger() {
        try {
            return new BigInteger(readString());
        } catch (NumberFormatException e) {
            throw new InputMismatchException();
        }
    }

    public char readCharacter() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        return (char) c;
    }

    public double readDouble() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        double res = 0;
        while (!isSpaceChar(c) && c != '.') {
            if (c == 'e' || c == 'E')
                return res * Math.pow(10, readInt());
            if (c < '0' || c > '9')
                throw new InputMismatchException();
            res *= 10;
            res += c - '0';
            c = read();
        }
        if (c == '.') {
            c = read();
            double m = 1;
            while (!isSpaceChar(c)) {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, readInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                m /= 10;
                res += (c - '0') * m;
                c = read();
            }
        }
        return res * sgn;
    }

    public boolean isExhausted() {
        int value;
        while (isSpaceChar(value = peek()) && value != -1)
            read();
        return value == -1;
    }

    public String next() {
        return readString();
    }

    public boolean readBoolean() {
        return readInt() == 1;
    }
}
