using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace bug
{
    class Program
    {
        static void bug(int i, int j, int[] a,int k, ref long z)
        {
            if (k == 0) z = z + zbir(i, j, a);
            else
            {
                for (int l = i; l < j; l++)
                    for (int m = l + 1; m <= j; m++) bug(l, m, a, k - 1, ref z);
            }

        }
        static long zbir(int i, int j, int[] a)
        {
            long z = 0;
            for (int n = i; n < j; n++) z = z + a[n];
            return z;
        }
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split();
            int n = int.Parse(s[0]);
            int k = int.Parse(s[1]);
            int[] a = new int[n];
            string[] s1 = Console.ReadLine().Split();
            for (int i = 0; i < n; i++) a[i] = int.Parse(s1[i]);
            long z = 0;
            bug(0, n, a, k, ref z);
            Console.WriteLine(z);
        }
    }
}