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

namespace ConsoleApp3
{

    class Program
    {
        public static T[] SubArray<T>(T[] array, int offset, int length)
        {
            T[] result = new T[length];
            Array.Copy(array, offset, result, 0, length);
            return result;
        }
        static int F(int []a,int k)
        {
            int zbir = 0;
            if (k == 0)
            {
                for (int i = 0; i < a.Length; i++)
                {
                    zbir += a[i];
                }
            }
            if(k>0)
            {
                for (int i = 0; i < a.Length; i++)
                {
                    int zbir1 = 0;
                    for (int j = i; j < a.Length; j++)
                    {
                        int[] a1 = SubArray(a, i, j - i +1);
                        zbir1 += F(a1, k - 1);
                    }
                    zbir += zbir1;
                }
            }
            return zbir;
        }
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split();
            int n = int.Parse(s[0]);
            int k = int.Parse(s[1]);
            string[] st = Console.ReadLine().Split();
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = int.Parse(st[i]);
            }
            int zbir = F(a,k);
            Console.WriteLine(zbir);
        }
    }
}