using System;

namespace Takmicenje_4
{
    class Program
    {
        static long rec(long[] a,int k,int off,int len)
        {
            long n = 0;
            if (k == 0) { for (int i = off; i < off+len; i++) n += a[i]; return n; }
            else {
                for (int i = off; i < off + len; i++) for (int j = i; j < off + len; j++) n += rec(a, k - 1, i, j - i + 1);
                return n;
                 }
        }
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split();
            int n = int.Parse(s[0]);
            int k = int.Parse(s[1]);
            long[] niz = new long[n];
            s = Console.ReadLine().Split();
            for(int i = 0; i < n; i++)
            {
                niz[i] = long.Parse(s[i]);
            }
            Console.WriteLine(rec(niz, k, 0, n));
        }
    }
}