import java.io.*;
import java.util.*;
import java.math.*;

public class smbh_ab implements Runnable {

	final int MAXN = 100;
	final int MAXD = 1000;
	final int MAXW = 1000;
	
	private void solve() throws IOException {
		int n = in.nextInt();
		assert 1 <= n && n <= MAXN;
		int D = in.nextInt();
		assert 0 <= D && D <= MAXD;
		int[] w = new int[n];
		for (int i = 0; i < n; ++i) {
			w[i] = in.nextInt();
			assert 1 <= w[i] && w[i] <= MAXW;
		}
		ArrayList<Integer> pos = new ArrayList<Integer>();
		pos.add(0);
		for (int i = 1; i <= n; ++i) {
			pos.add(i);
			if (D >= i) {
				pos.add(i);
			}
		}
		Collections.sort(pos);
		Arrays.sort(w);
		long ans = 0;
		for (int i = 0; i < w.length; ++i) {
			ans += w[w.length - 1 - i] * pos.get(i);
		}
		
		out.println(ans);
	}

	final String FILE_NAME = "smbh";

	SimpleScanner in;
	PrintWriter out;

	@Override
	public void run() {
		try {
			in = new SimpleScanner(new FileReader(FILE_NAME + ".in"));
			out = new PrintWriter(FILE_NAME + ".out");
			solve();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			System.exit(-1);
		}
	}

	public static void main(String[] args) {
		new Thread(new smbh_ab()).start();
	}

	class SimpleScanner extends BufferedReader {

		private StringTokenizer st;
		private boolean eof;

		public SimpleScanner(Reader a) {
			super(a);
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(readLine());
				} catch (Exception e) {
					eof = true;
					return "";
				}
			}
			return st.nextToken();
		}

		boolean seekEof() {
			String s = next();
			if ("".equals(s) && eof)
				return true;
			st = new StringTokenizer(s + " " + st.toString());
			return false;
		}

		private String cnv(String s) {
			if (s.length() == 0)
				return "0";
			return s;
		}

		int nextInt() {
			return Integer.parseInt(cnv(next()));
		}

		double nextDouble() {
			return Double.parseDouble(cnv(next()));
		}

		long nextLong() {
			return Long.parseLong(cnv(next()));
		}
	}
}