using System;
using System.Collections;
using System.Collections.Generic;

class g { static public int br; }

class HelloWorld
{ 
    static void racunaj(int[] a,int l,int d)
    {
        if (l == d)
        {
            if (g.br < a[l]) g.br = a[l];
        } else
        {
            int[] a1 = a;
            a[l] -= a[d];
            racunaj(a, l, d - 1);
            a1[d] -= a1[l];
            racunaj(a1, l + 1, d);
        }
    }
    static void komb(int[] a,int[] b,int n,int br,int no1, int k)
{
    if (br == n)
    {
        int[] c = new int[k]; int f = 0;
            if (no1 == k)
            {
                for (int i = 0; i < n; i++)
                {
                    if (b[i] == 1) { c[f] = a[i]; f++; }
                }
                racunaj(c,0,k-1);
            }
    } else
    {
        for (int i = 0; i <= 1; i++)
        {
                b[br] = i;
                if (i == 1) komb(a, b, n, br + 1 , no1 + 1, k); else komb(a, b, n, br + 1, no1 , k);
            }
    }
}
    static void Main()
    {
        g.br = -100000000;
        string[] s= Console.ReadLine().Split(' ');
        int n = int.Parse(s[0]);
        int k = int.Parse(s[1]);
        int[] a=new int[n];
        int[] b=new int[n];
        s= Console.ReadLine().Split(' ');
        for (int i = 0;i < n; i++)
        {
            a[i]=int.Parse(s[i]);
        }
        komb(a, b, n, 0, 0, k);
        Console.WriteLine(g.br);
    }
}