import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class servers_va {
    public static void main(String[] args) {
        new servers_va().run();
    }

    BufferedReader br;
    StringTokenizer st;
    PrintWriter out;

    public String nextToken() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }

    public int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    public int solve(int k, int[] w) throws IOException {
        int ans = 0;
        Arrays.sort(w);
        for (int i = 0; i < w.length; i++) {
            int part = i / k;
            ans += w[w.length - i - 1] * (part + 1);
        }

        return ans;
    }

    public void run() {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);

            int n = nextInt();
            int k = nextInt();
            int[] w = new int[n];

            for (int i = 0; i < n; i++) {
                w[i] = nextInt();
            }

            out.println(solve(k, w));

            out.close();
        } catch (IOException e) {
        }
    }
}
