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

namespace ConsoleApplication69
{
    class Program
    {
        static int f(int[] a, int k, int n)
        {
            if (k == 1)
            {
                int s = 0;
                for (int i = 0; i < n; i++)
                {
                    s += a[i] * (n - 1) * (n + 1);
                }
                return (s);
            }
            else
            {

            }
        }
        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];
            int s1 = 0; 
            s = Console.ReadLine().Split();
            if(k==0)
            { 
                for(int i = 0; i<n; i++)
                {
                    a[i] = int.Parse(s[i]);
                    s1 += a[i];
                }
                Console.WriteLine(s1);
            }
            else
            {
                Console.WriteLine(f(a, k, n));
            }
        }
    }
}