using System;

namespace drugi_krug
{
    class Program
    {
        static void Main(string[] args)
        {
            int n, k, s, zbir = 0;
            string[] p = Console.ReadLine().Split();
            n = Convert.ToInt32(p[0]);
            k = Convert.ToInt32(p[1]);
            int[] a = new int[n];
            p = Console.ReadLine().Split();
            for (int i = 0; i < n; i++)
            {
                a[i] = Convert.ToInt32(p[i]);
            }
            if (k==1)
            {
                for (int i = 0; i < n; i++)
                {
                    for (int j = i; j < n; j++)
                    {
                        s = n - j;
                        zbir += a[j] * s;
                    }
                }
            }
            if (k == 0)
            {
                for (int i = 0; i < n; i++)
                {
                    zbir += a[i];
                }
            }
            Console.WriteLine(zbir);
        }
    }
}