Your friend gave you a dequeue D as a birthday present.

D is a horizontal cylinder that contains a row of N jewels.

The values of the jewels are V_1, V_2, ..., V_N from left to right. There may be jewels with negative values.

In the beginning, you have no jewel in your hands.

You can perform at most K operations on D, chosen from the following, at most K times (possibly zero):

* Operation A: Take out the leftmost jewel contained in D and have it in your hand. You cannot do this operation when D is empty.

* Operation B: Take out the rightmost jewel contained in D and have it in your hand. You cannot do this operation when D is empty.

* Operation C: Choose a jewel in your hands and insert it to the left end of D. You cannot do this operation when you have no jewel in your hand.

* Operation D: Choose a jewel in your hands and insert it to the right end of D. You cannot do this operation when you have no jewel in your hand.




Find the maximum possible sum of the values of jewels in your hands after the operations.

Constraints

* All values in input are integers.
* 1 \leq N \leq 50
* 1 \leq K \leq 100
* -10^7 \leq V_i \leq 10^7

Input

Input is given from Standard Input in the following format:


N K
V_1 V_2 ... V_N


Output

Print the maximum possible sum of the values of jewels in your hands after the operations.

Examples

Input

6 4
-10 8 2 1 2 6


Output

14


Input

6 4
-6 -100 50 -2 -5 -3


Output

44


Input

6 3
-6 -100 50 -2 -5 -3


Output

0
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.Collections;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author cunbidun
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DEqueue solver = new DEqueue();
        solver.solve(1, in, out);
        out.close();
    }

    static class DEqueue {
        private static final int INF = (int) 2e9 + 7;
        private InputReader in;
        private PrintWriter out;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            this.in = in;
            this.out = out;
            int n = in.nextInt();
            int k = in.nextInt();
            int[] a = in.nextIntArray(n, 1);
            int ans = 0;
            for (int l = 0; l <= n; l++) {
                for (int r = 0; r <= n; r++) {
                    if (l + r <= MaxMin.Min(n, k)) {
                        int cur = 0;
                        ArrayList<Integer> L = new ArrayList<>();
                        L.add(-INF);
                        ArrayList<Integer> R = new ArrayList<>();
                        R.add(-INF);
                        for (int i = 1; i <= l; i++)
                            L.add(a[i]);
                        for (int i = n; i >= n - r + 1; i--)
                            R.add(a[i]);
                        int[] curL = new int[L.size()];
                        int[] curR = new int[R.size()];


                        Collections.sort(L);
                        Collections.sort(R);
//                    System.out.println(l + " " + r);

//                    for (int i : L) System.out.print(i + " ");
//                    System.out.println();
//                    for (int i : R) System.out.print(i + " ");
//                    System.out.println();

                        for (int i = 1; i <= l; i++) {
                            curL[i] = curL[i - 1] + L.get(i);
                        }
                        for (int i = 1; i <= r; i++) {
                            curR[i] = curR[i - 1] + R.get(i);
                        }

                        int num = l + r;
                        for (int i = 0; i <= l; i++) {
                            for (int j = 0; j <= r; j++) {
                                if (i + j + num <= k) {
                                    cur = MaxMin.Max(cur, curL[l] + curR[r] - (curL[i] + curR[j]));
                                }
                            }
                        }
                        ans = MaxMin.Max(ans, cur);
                    }
                }
            }
            out.println(ans);
        }

    }

    static class InputReader extends InputStream {
        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 nextInt() {
            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 int[] nextIntArray(int length, int stIndex) {
            int[] arr = new int[length + stIndex];
            for (int i = stIndex; i < stIndex + length; i++)
                arr[i] = nextInt();
            return arr;
        }

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

    }

    static class MaxMin {
        public static <T extends Comparable<T>> T Max(T x, T y) {
            T max = x;
            if (y.compareTo(max) > 0) max = y;
            return max;
        }

        public static <T extends Comparable<T>> T Min(T x, T y) {
            T min = x;
            if (y.compareTo(min) < 0) min = y;
            return min;
        }

    }
}

