import java.util.Scanner;

public class treci {

    public static void main(String[] args) {
        int s = 0;
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int k = sc.nextInt();
        int[] arr = new int[N];
        for (int i = 0; i < N; i++) {
            arr[i] = sc.nextInt();
        }

        if (k == 0) {
            for (int i = 0; i < N; i++) {
                s += arr[i];
            }
        } else {
            for (int g = 0; g < k; g++) {
                for (int i = 0; i < N; i++) {
                    for (int j = i; j < N; j++) {
                        for (int l = i; l < j + 1; l++) {
                            s += arr[l];
                        }
                    }

                }
            }
        }
        System.out.println(s);
    }
}