import java.io.*;

/**
 * Created by James on 1/29/2015.
 */

public class Driver {
    public static void main(String [] args) throws IOException {
        BufferedReader scanner = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);

        String [] pieces = scanner.readLine().split("\\s+");

        int N = Integer.parseInt(pieces[0]), D = Integer.parseInt(pieces[1]), count = 0, prev;

        pieces = scanner.readLine().split("\\s+");
        prev = Integer.parseInt(pieces[0]);

        for (int i = 1; i < N; ++i) {
            int cur = Integer.parseInt(pieces[i]);

            if (cur <= prev) {
                int diff = (int)Math.ceil((prev - cur) / (double)D);
                diff = Math.max(diff, 1);
                count += diff;
                cur += diff * D;
            }

            prev = cur;
        }

        out.println(count);
        out.close();
    }
}


import java.io.*;

/**
 * Created by James on 1/29/2015.
 */

public class Driver {
    public static void main(String [] args) throws IOException {
        BufferedReader scanner = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);

        String [] pieces = scanner.readLine().split("\\s+");

        int N = Integer.parseInt(pieces[0]), D = Integer.parseInt(pieces[1]), count = 0, prev;

        pieces = scanner.readLine().split("\\s+");
        prev = Integer.parseInt(pieces[0]);

        for (int i = 1; i < N; ++i) {
            int cur = Integer.parseInt(pieces[i]);

            if (cur <= prev) {
                int diff = (int)Math.ceil((prev + 1 - cur) / (double)D);
                diff = Math.max(diff, 1);
                count += diff;
                cur += diff * D;
            }

            prev = cur;
        }

        out.println(count);
        out.close();
    }
}


import java.io.*;

/**
 * Created by James on 1/29/2015.
 */

public class Driver {
    public static void main(String [] args) throws IOException {
        BufferedReader scanner = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);

        String [] pieces = scanner.readLine().split("\\s+");

        int N = Integer.parseInt(pieces[0]), D = Integer.parseInt(pieces[1]), count = 0, prev;

        pieces = scanner.readLine().split("\\s+");
        prev = Integer.parseInt(pieces[0]);

        for (int i = 1; i < N; ++i) {
            int cur = Integer.parseInt(pieces[i]);

            while (cur <= prev) {
                cur += D;
                count++;
            }

            prev = cur;
        }

        out.println(count);
        out.close();
    }
}


import java.awt.geom.AffineTransform;
import java.io.*;
import java.util.*;

public class A1008 {
    public static void main(String [] args) /*throws Exception*/ {
        InputStream inputReader = System.in;
        OutputStream outputReader = System.out;
        InputReader in = new InputReader(inputReader);//new InputReader(new FileInputStream(new File("input.txt")));new InputReader(inputReader);
        PrintWriter out = new PrintWriter(outputReader);//new PrintWriter(new FileOutputStream(new File("output.txt")));
        Algorithm solver = new Algorithm();
        solver.solve(in, out);
        out.close();
    }
}

class Algorithm {
    void solve(InputReader ir, PrintWriter pw) {

        int n = ir.nextInt(), d = ir.nextInt(), count = 0;
        int [] b = new int[n];

        for (int i = 0; i < n; i++) b[i] = ir.nextInt();

        for (int i = 1, num; i < n; i++) {
            num = b[i - 1] - b[i];
            if (num >= 0) {
                count += num / d + 1;
                b[i] += num + d;
            }
        }

        pw.print(count);

    }

    boolean isPolyndrom(String str) {
        StringBuilder newStr = new StringBuilder();
        for (int i = str.length() - 1; i >= 0; i--) newStr.append(str.charAt(i));
        return newStr.toString().equals(str);
    }

    private static void Qsort(int[] array, int low, int high) {

        int i = low;
        int j = high;
        int x = array[low + (high - low) / 2];

        do {
            while (array[i] < x) ++i;
            while (array[j] > x) --j;
            if (i <= j) {
                int tmp = array[i];
                array[i] = array[j];
                array[j] = tmp;
                i++;
                j--;
            }
        } while (i <= j);

        if (low < j) Qsort(array, low, j);
        if (i < high) Qsort(array, i, high);

    }
}

class InputReader {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream), 32768);
        tokenizer = null;
    }

    String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    String nextLine(){
        String fullLine = null;
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                fullLine = reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return fullLine;
        }
        return fullLine;
    }

    String [] toArray() {
        return nextLine().split(" ");
    }

    int nextInt() {
        return Integer.parseInt(next());
    }
    double nextDouble() {
        return Double.parseDouble(next());
    }
    long nextLong() {
        return Long.parseLong(next());
    }

}


import java.awt.geom.AffineTransform;
import java.io.*;
import java.util.*;

public class A1008 {
    public static void main(String [] args) /*throws Exception*/ {
        InputStream inputReader = System.in;
        OutputStream outputReader = System.out;
        InputReader in = new InputReader(inputReader);//new InputReader(new FileInputStream(new File("input.txt")));new InputReader(inputReader);
        PrintWriter out = new PrintWriter(outputReader);//new PrintWriter(new FileOutputStream(new File("output.txt")));
        Algorithm solver = new Algorithm();
        solver.solve(in, out);
        out.close();
    }
}

class Algorithm {
    void solve(InputReader ir, PrintWriter pw) {

        int n = ir.nextInt(), d = ir.nextInt(), count = 0;
        int [] b = new int[n];

        for (int i = 0; i < n; i++) b[i] = ir.nextInt();

        for (int i = 1, num; i < n; i++) {
            num = b[i - 1] - b[i];
            if (num >= 0) {
                count += num / d + 1;
                b[i] += num / d + 1;
            }
        }

        pw.print(count);

    }

    boolean isPolyndrom(String str) {
        StringBuilder newStr = new StringBuilder();
        for (int i = str.length() - 1; i >= 0; i--) newStr.append(str.charAt(i));
        return newStr.toString().equals(str);
    }

    private static void Qsort(int[] array, int low, int high) {

        int i = low;
        int j = high;
        int x = array[low + (high - low) / 2];

        do {
            while (array[i] < x) ++i;
            while (array[j] > x) --j;
            if (i <= j) {
                int tmp = array[i];
                array[i] = array[j];
                array[j] = tmp;
                i++;
                j--;
            }
        } while (i <= j);

        if (low < j) Qsort(array, low, j);
        if (i < high) Qsort(array, i, high);

    }
}

class InputReader {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream), 32768);
        tokenizer = null;
    }

    String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    String nextLine(){
        String fullLine = null;
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                fullLine = reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return fullLine;
        }
        return fullLine;
    }

    String [] toArray() {
        return nextLine().split(" ");
    }

    int nextInt() {
        return Integer.parseInt(next());
    }
    double nextDouble() {
        return Double.parseDouble(next());
    }
    long nextLong() {
        return Long.parseLong(next());
    }

}


import java.awt.geom.AffineTransform;
import java.io.*;
import java.util.*;

public class A1008 {
    public static void main(String [] args) /*throws Exception*/ {
        InputStream inputReader = System.in;
        OutputStream outputReader = System.out;
        InputReader in = new InputReader(inputReader);//new InputReader(new FileInputStream(new File("input.txt")));new InputReader(inputReader);
        PrintWriter out = new PrintWriter(outputReader);//new PrintWriter(new FileOutputStream(new File("output.txt")));
        Algorithm solver = new Algorithm();
        solver.solve(in, out);
        out.close();
    }
}

class Algorithm {
    void solve(InputReader ir, PrintWriter pw) {

        int n = ir.nextInt(), d = ir.nextInt(), count = 0;
        int [] b = new int[n];

        for (int i = 0; i < n; i++) b[i] = ir.nextInt();

        for (int i = 1, num; i < n; i++) {
            num = b[i - 1] - b[i];
            if (num >= 0) {
                count += num / d + 1;
                b[i] += d * (num / d + 1);
            }
        }

        pw.print(count);

    }

    boolean isPolyndrom(String str) {
        StringBuilder newStr = new StringBuilder();
        for (int i = str.length() - 1; i >= 0; i--) newStr.append(str.charAt(i));
        return newStr.toString().equals(str);
    }

    private static void Qsort(int[] array, int low, int high) {

        int i = low;
        int j = high;
        int x = array[low + (high - low) / 2];

        do {
            while (array[i] < x) ++i;
            while (array[j] > x) --j;
            if (i <= j) {
                int tmp = array[i];
                array[i] = array[j];
                array[j] = tmp;
                i++;
                j--;
            }
        } while (i <= j);

        if (low < j) Qsort(array, low, j);
        if (i < high) Qsort(array, i, high);

    }
}

class InputReader {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream), 32768);
        tokenizer = null;
    }

    String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    String nextLine(){
        String fullLine = null;
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                fullLine = reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return fullLine;
        }
        return fullLine;
    }

    String [] toArray() {
        return nextLine().split(" ");
    }

    int nextInt() {
        return Integer.parseInt(next());
    }
    double nextDouble() {
        return Double.parseDouble(next());
    }
    long nextLong() {
        return Long.parseLong(next());
    }

}


import java.util.ArrayList;
import java.util.InputMismatchException;
import java.util.Locale;
import java.util.Scanner;
import java.util.regex.Pattern;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;

public class Main {

	public static void main(String[] args) throws Exception {
        solve(1);
    }

    public static void solve(int testCases) throws Exception{

    	int n = StdIn.readInt();
    	int d = StdIn.readInt();
    	int[] b = new int[n];
    	for(int i = 0 ; i < n ; i++) b[i] = StdIn.readInt();
    	int moves = 0;
    	for(int i = 1 ; i < n ; i++){
    		if(b[i] > b[i-1])
    			continue;
    		else if(b[i] == b[i-1]){
    			b[i] = b[i-1] + d;
    			moves++;
    			continue;
    		}
    		int diff = (b[i-1] - b[i] + 1);
    		int count = (diff/d);
    		if(diff % d == 0){
    			moves += count;
    			b[i] += (count * d);
    		}
    		else{
    			moves += (count + 1);
    			b[i] += (count+1)*d;
    		}
    		//StdOut.println(i + " : " + moves);
    	}
    	StdOut.println(moves);
    }

}

final class StdIn {

    private StdIn() { }

    private static Scanner scanner;

    private static final String CHARSET_NAME = "UTF-8";

    private static final Locale LOCALE = Locale.US;

    private static final Pattern WHITESPACE_PATTERN = Pattern.compile("\\p{javaWhitespace}+");

    private static final Pattern EMPTY_PATTERN = Pattern.compile("");

    private static final Pattern EVERYTHING_PATTERN = Pattern.compile("\\A");

    public static boolean isEmpty() {
        return !scanner.hasNext();
    }

    public static boolean hasNextLine() {
        return scanner.hasNextLine();
    }

    public static boolean hasNextChar() {
        scanner.useDelimiter(EMPTY_PATTERN);
        boolean result = scanner.hasNext();
        scanner.useDelimiter(WHITESPACE_PATTERN);
        return result;
    }

    public static String readLine() {
        String line;
        try                 { line = scanner.nextLine(); }
        catch (Exception e) { line = null;               }
        return line;
    }

    public static char readChar() {
        scanner.useDelimiter(EMPTY_PATTERN);
        String ch = scanner.next();
        assert (ch.length() == 1) : "Internal (Std)In.readChar() error!"
            + " Please contact the authors.";
        scanner.useDelimiter(WHITESPACE_PATTERN);
        return ch.charAt(0);
    }

    public static String readAll() {
        if (!scanner.hasNextLine())
            return "";

        String result = scanner.useDelimiter(EVERYTHING_PATTERN).next();
        // not that important to reset delimeter, since now scanner is empty
        scanner.useDelimiter(WHITESPACE_PATTERN); // but let's do it anyway
        return result;
    }

    public static String readString() {
        return scanner.next();
    }

    public static int readInt() {
        return scanner.nextInt();
    }

    public static double readDouble() {
        return scanner.nextDouble();
    }

    public static float readFloat() {
        return scanner.nextFloat();
    }

    public static long readLong() {
        return scanner.nextLong();
    }

    public static short readShort() {
        return scanner.nextShort();
    }

    public static byte readByte() {
        return scanner.nextByte();
    }

    public static boolean readBoolean() {
        String s = readString();
        if (s.equalsIgnoreCase("true"))  return true;
        if (s.equalsIgnoreCase("false")) return false;
        if (s.equals("1"))               return true;
        if (s.equals("0"))               return false;
        throw new InputMismatchException();
    }

    public static String[] readAllStrings() {
        // we could use readAll.trim().split(), but that's not consistent
        // because trim() uses characters 0x00..0x20 as whitespace
        String[] tokens = WHITESPACE_PATTERN.split(readAll());
        if (tokens.length == 0 || tokens[0].length() > 0)
            return tokens;

        // don't include first token if it is leading whitespace
        String[] decapitokens = new String[tokens.length-1];
        for (int i = 0; i < tokens.length - 1; i++)
            decapitokens[i] = tokens[i+1];
        return decapitokens;
    }

    public static String[] readAllLines() {
        ArrayList<String> lines = new ArrayList<String>();
        while (hasNextLine()) {
            lines.add(readLine());
        }
        return lines.toArray(new String[0]);
    }

    public static int[] readAllInts() {
        String[] fields = readAllStrings();
        int[] vals = new int[fields.length];
        for (int i = 0; i < fields.length; i++)
            vals[i] = Integer.parseInt(fields[i]);
        return vals;
    }

    public static double[] readAllDoubles() {
        String[] fields = readAllStrings();
        double[] vals = new double[fields.length];
        for (int i = 0; i < fields.length; i++)
            vals[i] = Double.parseDouble(fields[i]);
        return vals;
    }

    static {
        resync();
    }

    private static void resync() {
        setScanner(new Scanner(new java.io.BufferedInputStream(System.in), CHARSET_NAME));
    }

    private static void setScanner(Scanner scanner) {
        StdIn.scanner = scanner;
        StdIn.scanner.useLocale(LOCALE);
    }

    public static int[] readInts() {
        return readAllInts();
    }

    public static double[] readDoubles() {
        return readAllDoubles();
    }

    public static String[] readStrings() {
        return readAllStrings();
    }

}

final class StdOut {

    private static final String CHARSET_NAME = "UTF-8";

    private static final Locale LOCALE = Locale.US;

    private static PrintWriter out;

    static {
        try {
            out = new PrintWriter(new OutputStreamWriter(System.out, CHARSET_NAME), true);
        }
        catch (UnsupportedEncodingException e) { System.out.println(e); }
    }

    private StdOut() { }

    public static void close() {
        out.close();
    }

    public static void println() {
        out.println();
    }

    public static void println(Object x) {
        out.println(x);
    }

    public static void println(boolean x) {
        out.println(x);
    }

    public static void println(char x) {
        out.println(x);
    }

    public static void println(double x) {
        out.println(x);
    }

    public static void println(float x) {
        out.println(x);
    }

    public static void println(int x) {
        out.println(x);
    }

    public static void println(long x) {
        out.println(x);
    }

    public static void println(short x) {
        out.println(x);
    }

    public static void println(byte x) {
        out.println(x);
    }

    public static void print() {
        out.flush();
    }

    public static void print(Object x) {
        out.print(x);
        out.flush();
    }

    public static void print(boolean x) {
        out.print(x);
        out.flush();
    }

    public static void print(char x) {
        out.print(x);
        out.flush();
    }

    public static void print(double x) {
        out.print(x);
        out.flush();
    }

    public static void print(float x) {
        out.print(x);
        out.flush();
    }

    public static void print(int x) {
        out.print(x);
        out.flush();
    }

    public static void print(long x) {
        out.print(x);
        out.flush();
    }

    public static void print(short x) {
        out.print(x);
        out.flush();
    }

    public static void print(byte x) {
        out.print(x);
        out.flush();
    }

    public static void printf(String format, Object... args) {
        out.printf(LOCALE, format, args);
        out.flush();
    }

    public static void printf(Locale locale, String format, Object... args) {
        out.printf(locale, format, args);
        out.flush();
    }

}


import java.util.ArrayList;
import java.util.InputMismatchException;
import java.util.Locale;
import java.util.Scanner;
import java.util.regex.Pattern;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;

public class Main {

	public static void main(String[] args) throws Exception {
        solve(1);
    }

    public static void solve(int testCases) throws Exception{

    	int n = StdIn.readInt();
    	int d = StdIn.readInt();
    	int[] b = new int[n];
    	for(int i = 0 ; i < n ; i++) b[i] = StdIn.readInt();
    	int moves = 0;
    	for(int i = 1 ; i < n ; i++){
    		if(b[i] > b[i-1])
    			continue;
    		else if(b[i] == b[i-1]){
    			b[i] = b[i-1] + d;
    			moves++;
    			continue;
    		}
    		int diff = b[i-1] - b[i];
    		int count = (diff/d);
    		if(diff % d == 0){
    			moves += count;
    			b[i] += (count * d);
    		}
    		else{
    			moves += (count + 1);
    			b[i] += (count+1)*d;
    		}

    	}
    	StdOut.println(moves);
    }

}

final class StdIn {

    private StdIn() { }

    private static Scanner scanner;

    private static final String CHARSET_NAME = "UTF-8";

    private static final Locale LOCALE = Locale.US;

    private static final Pattern WHITESPACE_PATTERN = Pattern.compile("\\p{javaWhitespace}+");

    private static final Pattern EMPTY_PATTERN = Pattern.compile("");

    private static final Pattern EVERYTHING_PATTERN = Pattern.compile("\\A");

    public static boolean isEmpty() {
        return !scanner.hasNext();
    }

    public static boolean hasNextLine() {
        return scanner.hasNextLine();
    }

    public static boolean hasNextChar() {
        scanner.useDelimiter(EMPTY_PATTERN);
        boolean result = scanner.hasNext();
        scanner.useDelimiter(WHITESPACE_PATTERN);
        return result;
    }

    public static String readLine() {
        String line;
        try                 { line = scanner.nextLine(); }
        catch (Exception e) { line = null;               }
        return line;
    }

    public static char readChar() {
        scanner.useDelimiter(EMPTY_PATTERN);
        String ch = scanner.next();
        assert (ch.length() == 1) : "Internal (Std)In.readChar() error!"
            + " Please contact the authors.";
        scanner.useDelimiter(WHITESPACE_PATTERN);
        return ch.charAt(0);
    }

    public static String readAll() {
        if (!scanner.hasNextLine())
            return "";

        String result = scanner.useDelimiter(EVERYTHING_PATTERN).next();
        // not that important to reset delimeter, since now scanner is empty
        scanner.useDelimiter(WHITESPACE_PATTERN); // but let's do it anyway
        return result;
    }

    public static String readString() {
        return scanner.next();
    }

    public static int readInt() {
        return scanner.nextInt();
    }

    public static double readDouble() {
        return scanner.nextDouble();
    }

    public static float readFloat() {
        return scanner.nextFloat();
    }

    public static long readLong() {
        return scanner.nextLong();
    }

    public static short readShort() {
        return scanner.nextShort();
    }

    public static byte readByte() {
        return scanner.nextByte();
    }

    public static boolean readBoolean() {
        String s = readString();
        if (s.equalsIgnoreCase("true"))  return true;
        if (s.equalsIgnoreCase("false")) return false;
        if (s.equals("1"))               return true;
        if (s.equals("0"))               return false;
        throw new InputMismatchException();
    }

    public static String[] readAllStrings() {
        // we could use readAll.trim().split(), but that's not consistent
        // because trim() uses characters 0x00..0x20 as whitespace
        String[] tokens = WHITESPACE_PATTERN.split(readAll());
        if (tokens.length == 0 || tokens[0].length() > 0)
            return tokens;

        // don't include first token if it is leading whitespace
        String[] decapitokens = new String[tokens.length-1];
        for (int i = 0; i < tokens.length - 1; i++)
            decapitokens[i] = tokens[i+1];
        return decapitokens;
    }

    public static String[] readAllLines() {
        ArrayList<String> lines = new ArrayList<String>();
        while (hasNextLine()) {
            lines.add(readLine());
        }
        return lines.toArray(new String[0]);
    }

    public static int[] readAllInts() {
        String[] fields = readAllStrings();
        int[] vals = new int[fields.length];
        for (int i = 0; i < fields.length; i++)
            vals[i] = Integer.parseInt(fields[i]);
        return vals;
    }

    public static double[] readAllDoubles() {
        String[] fields = readAllStrings();
        double[] vals = new double[fields.length];
        for (int i = 0; i < fields.length; i++)
            vals[i] = Double.parseDouble(fields[i]);
        return vals;
    }

    static {
        resync();
    }

    private static void resync() {
        setScanner(new Scanner(new java.io.BufferedInputStream(System.in), CHARSET_NAME));
    }

    private static void setScanner(Scanner scanner) {
        StdIn.scanner = scanner;
        StdIn.scanner.useLocale(LOCALE);
    }

    public static int[] readInts() {
        return readAllInts();
    }

    public static double[] readDoubles() {
        return readAllDoubles();
    }

    public static String[] readStrings() {
        return readAllStrings();
    }

}

final class StdOut {

    private static final String CHARSET_NAME = "UTF-8";

    private static final Locale LOCALE = Locale.US;

    private static PrintWriter out;

    static {
        try {
            out = new PrintWriter(new OutputStreamWriter(System.out, CHARSET_NAME), true);
        }
        catch (UnsupportedEncodingException e) { System.out.println(e); }
    }

    private StdOut() { }

    public static void close() {
        out.close();
    }

    public static void println() {
        out.println();
    }

    public static void println(Object x) {
        out.println(x);
    }

    public static void println(boolean x) {
        out.println(x);
    }

    public static void println(char x) {
        out.println(x);
    }

    public static void println(double x) {
        out.println(x);
    }

    public static void println(float x) {
        out.println(x);
    }

    public static void println(int x) {
        out.println(x);
    }

    public static void println(long x) {
        out.println(x);
    }

    public static void println(short x) {
        out.println(x);
    }

    public static void println(byte x) {
        out.println(x);
    }

    public static void print() {
        out.flush();
    }

    public static void print(Object x) {
        out.print(x);
        out.flush();
    }

    public static void print(boolean x) {
        out.print(x);
        out.flush();
    }

    public static void print(char x) {
        out.print(x);
        out.flush();
    }

    public static void print(double x) {
        out.print(x);
        out.flush();
    }

    public static void print(float x) {
        out.print(x);
        out.flush();
    }

    public static void print(int x) {
        out.print(x);
        out.flush();
    }

    public static void print(long x) {
        out.print(x);
        out.flush();
    }

    public static void print(short x) {
        out.print(x);
        out.flush();
    }

    public static void print(byte x) {
        out.print(x);
        out.flush();
    }

    public static void printf(String format, Object... args) {
        out.printf(LOCALE, format, args);
        out.flush();
    }

    public static void printf(Locale locale, String format, Object... args) {
        out.printf(locale, format, args);
        out.flush();
    }

}


import java.util.Scanner;

public class Task11A {
    public static void main(String[] args) {
        Scanner scn = new Scanner(System.in);
        int n = scn.nextInt();
        int d = scn.nextInt();
        int[] b = new int[n];
        for (int i = 0; i < n; i++) {
            b[i] = scn.nextInt();
        }
        int x = 0;
        for (int i = 1; i < n; i++) {
            if (b[i] <= b[i - 1]) {
                int kol = (b[i - 1] - b[i]) / d + 1;
                x = x + kol;
                b[i] = b[i] + d * kol;
            }
        }
        System.out.println(x);
    }
}


import java.util.Scanner;

public class Task11A {
    public static void main(String[] args) {
        Scanner scn = new Scanner(System.in);
        int n = scn.nextInt();
        int d = scn.nextInt();
        int[] b = new int[n];
        for (int i = 0; i<n; i++){
            b[i]=scn.nextInt();
        }
        int x = 0;
        for (int i = 1; i<n; i++){
            while (b[i]<=b[i-1]){
                b[i]=b[i]+d;
                x++;
            }
        }
        System.out.println(x);
    }
}


import java.util.Scanner;
public class Increasing {
    static Scanner sr = new Scanner(System.in);
    public static void main(String args[]){
        int n = sr.nextInt();
        int d = sr.nextInt();
        int a[] = new int[n];
        for (int i = 0; i < n; i++){
            a[i] = sr.nextInt();
        }
        int b = 0;
        for (int i = 1; i < n; i++){
            if (a[i] <= a[i-1]){
           b = b + ((a[i-1]-a[i])/d + 1);
           a[i] = a[i] + d * ((a[i-1]-a[i])/d + 1);}
        }
        System.out.println(b);
    }
}


import java.util.*;
public class Increasing {
    static Scanner sr = new Scanner(System.in);
    public static void main(String args[]){
        int n = sr.nextInt();
        int d = sr.nextInt();
        int a[] = new int[n];
        for (int i = 0; i < n; i++){
            a[i] = sr.nextInt();
        }
        int b = 0;
        for (int i = 1; i < n; i++){
            while (a[i] <= a[i-1]) {
                 a[i] = a[i] + d;
                 b = b + 1;
            }
        }
        System.out.println(b);
    }
}


import java.util.Scanner;
public class Increasing {
    static Scanner sr = new Scanner(System.in);
    public static void main(String args[]){
        int n = sr.nextInt();
        int d = sr.nextInt();
        int a[] = new int[n];
        for (int i = 0; i < n; i++){
            a[i] = sr.nextInt();
        }
        int b = 0;
        for (int i = 1; i < n; i++){
            if (a[i] < a[i-1]){
           b = b + ((a[i-1]-a[i])/d + 1);
           a[i] = a[i] + d * ((a[i-1]-a[i])/d + 1);}
        }
        System.out.println(b);
    }
}


import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws IOException {

        Reader sc = new Reader();

        int n = sc.nextInt();
        int d = sc.nextInt();

        int ans = 0;

        int curr;
        int prev = sc.nextInt();
        int tries = 0;

        for (int i = 1; i < n; i++) {
            curr = sc.nextInt();

            while (true) {
                if (curr < prev) {
                    tries = (prev - curr + d - 1) / d;
                    ans += tries;
                    curr += tries * d;
                }
                else if (curr == prev) {
                    ans += 1;
                    curr += d;
                }
                else break;
            }

//            while (curr <= prev) {
//                ans++;
//                curr += d;
//            }

            prev = curr;
        }

        System.out.println(ans);
    }

    static class Reader
    {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public Reader()
        {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public Reader(String file_name) throws IOException
        {
            din = new DataInputStream(new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException
        {
            byte[] buf = new byte[64]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1)
            {
                if (c == '\n')
                    break;
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException
        {
            int ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do
            {
                ret = ret * 10 + c - '0';
            }  while ((c = read()) >= '0' && c <= '9');

            if (neg)
                return -ret;
            return ret;
        }

        public long nextLong() throws IOException
        {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public double nextDouble() throws IOException
        {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();

            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');

            if (c == '.')
            {
                while ((c = read()) >= '0' && c <= '9')
                {
                    ret += (c - '0') / (div *= 10);
                }
            }

            if (neg)
                return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException
        {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read() throws IOException
        {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException
        {
            if (din == null)
                return;
            din.close();
        }
    }
}


import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws IOException {

        Reader sc = new Reader();

        int n = sc.nextInt();
        int d = sc.nextInt();

        int ans = 0;

        int curr;
        int prev = sc.nextInt();
        int tries = 0;

        for (int i = 1; i < n; i++) {
            curr = sc.nextInt();

            if (curr <= prev) {
                tries = (prev - curr + d) / 2;
                ans += tries;
                curr += tries * d;
            }

//            while (curr <= prev) {
//                ans++;
//                curr += d;
//            }

            prev = curr;
        }

        System.out.println(ans);
    }

    static class Reader
    {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public Reader()
        {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public Reader(String file_name) throws IOException
        {
            din = new DataInputStream(new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException
        {
            byte[] buf = new byte[64]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1)
            {
                if (c == '\n')
                    break;
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException
        {
            int ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do
            {
                ret = ret * 10 + c - '0';
            }  while ((c = read()) >= '0' && c <= '9');

            if (neg)
                return -ret;
            return ret;
        }

        public long nextLong() throws IOException
        {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public double nextDouble() throws IOException
        {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();

            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');

            if (c == '.')
            {
                while ((c = read()) >= '0' && c <= '9')
                {
                    ret += (c - '0') / (div *= 10);
                }
            }

            if (neg)
                return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException
        {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read() throws IOException
        {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException
        {
            if (din == null)
                return;
            din.close();
        }
    }
}


import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws IOException {

        Reader sc = new Reader();

        int n = sc.nextInt();
        int d = sc.nextInt();

        int ans = 0;

        int curr;
        int prev = sc.nextInt();
        int tries = 0;

        for (int i = 1; i < n; i++) {
            curr = sc.nextInt();

            while (true) {
                if (curr < prev) {
                    tries = (prev - curr + d - 1) / 2;
                    ans += tries;
                    curr += tries * d;
                }
                else if (curr == prev) {
                    ans += 1;
                    curr += d;
                }
                else break;
            }

//            while (curr <= prev) {
//                ans++;
//                curr += d;
//            }

            prev = curr;
        }

        System.out.println(ans);
    }

    static class Reader
    {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public Reader()
        {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public Reader(String file_name) throws IOException
        {
            din = new DataInputStream(new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException
        {
            byte[] buf = new byte[64]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1)
            {
                if (c == '\n')
                    break;
                buf[cnt++] = (byte) c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException
        {
            int ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do
            {
                ret = ret * 10 + c - '0';
            }  while ((c = read()) >= '0' && c <= '9');

            if (neg)
                return -ret;
            return ret;
        }

        public long nextLong() throws IOException
        {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public double nextDouble() throws IOException
        {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();

            do {
                ret = ret * 10 + c - '0';
            }
            while ((c = read()) >= '0' && c <= '9');

            if (c == '.')
            {
                while ((c = read()) >= '0' && c <= '9')
                {
                    ret += (c - '0') / (div *= 10);
                }
            }

            if (neg)
                return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException
        {
            bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read() throws IOException
        {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException
        {
            if (din == null)
                return;
            din.close();
        }
    }
}


import java.util.Scanner;

public class IncreasingSequence {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n=scan.nextInt();
		int d=scan.nextInt();
		int b0=0,c=0;;
		while(n-->0)
		{
			int b=scan.nextInt();
			if(b<=b0)
			{
				int x=(b0-b)/d+1;
				c+=x;
				b0=b+x*d;
			}
			else
			{
				b0=b;
			}
		}
		System.out.println(c);
	}

}


import java.util.Scanner;

public class IncreasingSequence {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n=scan.nextInt();
		int d=scan.nextInt();
		int[] a=new int[n];
		for(int i=0;i<n;i++)
		{
			a[i]=scan.nextInt();
		}
		int c=0;
		for(int i=0;i<n;i++)
		{
			for(int j=i+1;j<n;j++)
			{
				if(a[i]<a[j])
				{
					continue;
				}
				else
				{
					a[i]+=d;
					c++;
				}
			}
		}
		System.out.println(c);
	}

}


import java.util.Scanner;
public class Main {
	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
		int n = Integer.parseInt(scan.next());
		int d = Integer.parseInt(scan.next());
		int[] b = new int[n];
		for(int i=0; i<n; i++)
			b[i] = Integer.parseInt(scan.next());
		int moves = 0;
		for(int i=1; i<n; i++)
		{
			if(b[i] <= b[i-1])
			{
				int k = (b[i-1]-b[i])/d;
				k++;
				moves+=k;
				b[i]+=k*d;
			}
		}
		System.out.println(moves);
	}

}


import java.util.Scanner;
public class Main {
	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int n = Integer.parseInt(scan.next());
			int d = Integer.parseInt(scan.next());
			int x,y, p;
			p=0;
			y=scan.nextInt();
			for(int i=1;i<n;i++){
				x= scan.nextInt();
				while(x<=y){
					x+=d;
					p++;
				}
				y=x;
			}
			System.out.println(p);
		}
	}
}


import java.util.Scanner;

public class IncreasingSequence {
	public static void main(String[] args) {
		Scanner scan= new Scanner(System.in);

		while(scan.hasNext()){
			int i,j,k=0, x,y,z;
			x= scan.nextInt();
			y=scan.nextInt();
			int arr[]= new int [x];
			for(i=0;i<x;i++){
				arr[i]=scan.nextInt();
			}

			for(i=0;i<x-1;){
				if(arr[i]<arr[i+1]){
					i++;
				}else{
					do{
						arr[i+1] =arr[i+1]+y;
						k++;
					}while(arr[i+1]<=arr[i]);
					i++;
				}
			}

			for(i=0;i<x;i++){
				System.out.print(arr[i]+" ");
			}
			System.out.println("\n"+k);
		}
	}
}


import java.util.Scanner;

public class IncreasingSequence {
	public static void main(String[] args) {
		Scanner scan= new Scanner(System.in);

		while(scan.hasNext()){
			int i,j,k=0, x,y,z;
			x= scan.nextInt();
			y=scan.nextInt();
			int arr[]= new int [x];
			for(i=0;i<x;i++){
				arr[i]=scan.nextInt();
			}

			for(i=0;i<x-1;){
				if(arr[i]<arr[i+1]){
					i++;
				}else{
					do{
						arr[i+1] =arr[i+1]+y;
						k++;
					}while(arr[i+1]<=arr[i]);
					i++;
				}
			}

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


public class IncreasingSequence {
	public static void main(String[] args) {
		try (java.util.Scanner sc = new java.util.Scanner(System.in)) {
			int n = sc.nextInt();
			int d = sc.nextInt();

			int s = 0;
			int[] b = new int[n];
			for (int i = 0; i < n; i++) {
				b[i] = sc.nextInt();
				if (i != 0 && b[i] <= b[i - 1]) {
					int diff = b[i - 1] - b[i];
					if (diff < d) {
						b[i] = b[i] + d;
						s++;
					} else {
						int aaa = (diff / d);
						int aa = d + aaa;
						b[i] = b[i] + aa;
						s += aaa + 1;
					}
				}
			}
			System.out.println(s);
		}
	}
}


public class IncreasingSequence {
	public static void main(String[] args) {
		try (java.util.Scanner sc = new java.util.Scanner(System.in)) {
			int n = sc.nextInt();
			int d = sc.nextInt();

			int s = 0;
			int bin = Integer.MIN_VALUE;
			for (int i = 0; i < n; i++) {
				int b = sc.nextInt();
				if (b <= bin) {
					int diff = (bin - b) / d + 1;
					s += diff;
					bin = b + diff * d;
				} else {
					bin = b;
				}
			}
			System.out.println(s);
		}
	}
}


import java.util.ArrayList;
import java.util.Scanner;
import java.util.stream.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		int n=0, d=0;
		ArrayList<Integer> container=new ArrayList<Integer>();
		Scanner scn=new Scanner(System.in);
		n=scn.nextInt();
		d=scn.nextInt();
		//I method
		for(int i=0; i<n; i++)
			container.add(scn.nextInt());
		//method II
		//container=(ArrayList<Integer>) Stream.of(scn.nextLine().split(" ")).map(Integer::parseInt).collect(Collectors.toList());

		scn.close();

	/*	System.out.print("n=" + n + "  d= " +d);
		System.out.println();
		System.out.print(container);
*/

		int ans=0;
		for(int i=0; i<n-1; i++) {
			if(container.get(i)>=container.get(i+1)) {
				//I method
				/*while(container.get(i)>=container.get(i+1)) {
					int item = container.get(i+1)+d;
					 container.set(i+1,item);
					 ans++;
				}
				//end while loop
				*/
			//method II
				int difference=container.get(i)-container.get(i+1);
				int required_d=difference/d+1;
				container.set(i+1, container.get(i+1)+required_d*d);
				ans+=required_d;

	}

		}
			//and for loop
		System.out.println(ans);

	}

}


import java.util.ArrayList;
import java.util.Scanner;
import java.util.stream.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		int n=0, d=0;
		ArrayList<Integer> container=new ArrayList<Integer>();
		Scanner scn=new Scanner(System.in);
		n=scn.nextInt();
		d=scn.nextInt();
		//I method
		for(int i=0; i<n; i++)
			container.add(scn.nextInt());
		//method II
		//container=(ArrayList<Integer>) Stream.of(scn.nextLine().split(" ")).map(Integer::parseInt).collect(Collectors.toList());

		scn.close();

	/*	System.out.print("n=" + n + "  d= " +d);
		System.out.println();
		System.out.print(container);
*/

		int ans=0;
		for(int i=0; i<n-1; i++) {
			if(container.get(i)>=container.get(i+1)) {
				while(container.get(i)>=container.get(i+1)) {
					int item = container.get(i+1)+d;
					 container.set(i+1,item);
					 ans++;
				}//end while loop
			}

		}
			//and for loop
		System.out.println(ans);

	}

}


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

public class P11A {

  private static void solve() {
    int n = nextInt();
    int d = nextInt();

    int last = nextInt();
    int ans = 0;
    for (int i = 1; i < n; i++) {
      int cur = nextInt();

      while (cur <= last) {
        cur += d;
        ans++;
      }
      last = cur;
    }

    System.out.println(ans);
  }

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

    solve();

    out.close();
  }

  private static StringTokenizer st;
  private static BufferedReader br;
  private static PrintWriter out;

  private static String next() {
    while (st == null || !st.hasMoreElements()) {
      String s;
      try {
        s = br.readLine();
      } catch (IOException e) {
        return null;
      }
      st = new StringTokenizer(s);
    }
    return st.nextToken();
  }

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

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

  public static void main(String[] args) {
    run();
  }
}


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

public class P11A {

  private static void solve() {
    int n = nextInt();
    int d = nextInt();

    int last = nextInt();
    long ans = 0;
    for (int i = 1; i < n; i++) {
      int cur = nextInt();

      if (cur < last) {
        int diff = last - cur;
        int count = diff / d + 1;
        cur += d * count;
        ans += count;
      } else if (cur == last) {
        cur += d;
        ans++;
      }
      last = cur;
    }

    System.out.println(ans);
  }

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

    solve();

    out.close();
  }

  private static StringTokenizer st;
  private static BufferedReader br;
  private static PrintWriter out;

  private static String next() {
    while (st == null || !st.hasMoreElements()) {
      String s;
      try {
        s = br.readLine();
      } catch (IOException e) {
        return null;
      }
      st = new StringTokenizer(s);
    }
    return st.nextToken();
  }

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

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

  public static void main(String[] args) {
    run();
  }
}


import java.util.Scanner;

public class IncreasingSequence {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(), d = in.nextInt();
        int[] nums = new int[n];
        int move = 0;
        for (int i = 0; i < n; i++) {
            nums[i] = in.nextInt();
            if (i > 0 && nums[i] <= nums[i-1]) {
                move += (nums[i-1] - nums[i])/d+1;
                nums[i] += d*move;
            }
        }
        System.out.println(move);
    }
}


import java.util.Scanner;

public class IncreasingSequence {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(), d = in.nextInt();
        int[] nums = new int[n];
        int move = 0;
        for (int i = 0; i < n; i++) {
            nums[i] = in.nextInt();
            if (i > 0) {
                while (nums[i] <= nums[i-1]) {
                    move++;
                    nums[i] += d;
                }
            }
        }
        System.out.println(move);
    }
}


import java.util.Scanner;

public class IncreasingSequence {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(), d = in.nextInt();
        int[] nums = new int[n];
        int move = 0;
        for (int i = 0; i < n; i++) {
            nums[i] = in.nextInt();
            if (i > 0 && nums[i] <= nums[i-1]) {
                int tmp = (nums[i-1] - nums[i])/d+1;
                move += tmp;
                nums[i] += d*tmp;
            }
        }
        System.out.println(move);
    }
}


import java.util.Scanner;

public class IncreasingSequence {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(), d = in.nextInt();
        int[] nums = new int[n];
        int move = 0;
        for (int i = 0; i < n; i++) {
            nums[i] = in.nextInt();
            if (i > 0) {
                move += (nums[i] - nums[i-1])/d+1;
                nums[i] += d*move;
            }
        }
        System.out.println(move);
    }
}


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

public class Main {
    public static void main(String[] args) throws IOException {
        InputStream inputStream = System.in;
//        InputStream inputStream = new FileInputStream("sum.in");
        OutputStream outputStream = System.out;
//        OutputStream outputStream = new FileOutputStream("sum.out");

//        Path path = Paths.get(URI.create("file:///foo/bar/Main.java"));
//        System.out.print(path.getName(200));

//        Path p = Paths.get("/foo/bar/Main.java");
//        for (Path e : p) {
//            System.out.println(e);
//        }

        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Answer solver = new Answer();
        solver.solve(in, out);
        out.close();
    }
}

class Answer {
    private final int INF = (int) (1e9 + 7);
    private final int MOD = (int) (1e9 + 7);
    private final int MOD1 = (int) (1e6 + 3);
    private final long INF_LONG = (long) (1e18 + 1);
    private final double EPS = 1e-9;

    public void solve(InputReader in, PrintWriter out) throws IOException {
        int n = in.nextInt();
        int d = in.nextInt();

        long[] b = in.nextArrayLong(n);

        long ans = 0;

        for (int i = 1; i < n; i++) {
            long kol = 0;
            if (b[i] < b[i - 1]) {
                kol = (b[i - 1] - b[i]) / d + 1;
            }
            ans += kol;
            b[i] += 1L * kol * d;
        }

        out.println(ans);

//        for (int i = 0; i < n; i++) {
//            out.print(b[i] + " ");
//        }

    }
}

class InputReader {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream), 32768);
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

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

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

    public int[] nextArrayInt(int count) {
        int[] a = new int[count];
        for (int i = 0; i < count; i++) {
            a[i] = nextInt();
        }
        return a;
    }

    public long[] nextArrayLong(int count) {
        long[] a = new long[count];
        for (int i = 0; i < count; i++) {
            a[i] = nextLong();
        }
        return a;
    }
}


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

public class Main {
    public static void main(String[] args) throws IOException {
        InputStream inputStream = System.in;
//        InputStream inputStream = new FileInputStream("sum.in");
        OutputStream outputStream = System.out;
//        OutputStream outputStream = new FileOutputStream("sum.out");

//        Path path = Paths.get(URI.create("file:///foo/bar/Main.java"));
//        System.out.print(path.getName(200));

//        Path p = Paths.get("/foo/bar/Main.java");
//        for (Path e : p) {
//            System.out.println(e);
//        }

        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Answer solver = new Answer();
        solver.solve(in, out);
        out.close();
    }
}

class Answer {
    private final int INF = (int) (1e9 + 7);
    private final int MOD = (int) (1e9 + 7);
    private final int MOD1 = (int) (1e6 + 3);
    private final long INF_LONG = (long) (1e18 + 1);
    private final double EPS = 1e-9;

    public void solve(InputReader in, PrintWriter out) throws IOException {
        int n = in.nextInt();
        int d = in.nextInt();

        long[] b = in.nextArrayLong(n);

        long ans = 0;

        for (int i = 1; i < n; i++) {
            long kol = 0;
            if (b[i] <= b[i - 1]) {
                kol = (b[i - 1] - b[i]) / d + 1;
            }
            ans += kol;
            b[i] += 1L * kol * d;
        }

        out.println(ans);

//        for (int i = 0; i < n; i++) {
//            out.print(b[i] + " ");
//        }

    }
}

class InputReader {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream), 32768);
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

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

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

    public int[] nextArrayInt(int count) {
        int[] a = new int[count];
        for (int i = 0; i < count; i++) {
            a[i] = nextInt();
        }
        return a;
    }

    public long[] nextArrayLong(int count) {
        long[] a = new long[count];
        for (int i = 0; i < count; i++) {
            a[i] = nextLong();
        }
        return a;
    }
}


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

public class Main {
    public static void main(String[] args) throws IOException {
        InputStream inputStream = System.in;
//        InputStream inputStream = new FileInputStream("sum.in");
        OutputStream outputStream = System.out;
//        OutputStream outputStream = new FileOutputStream("sum.out");

//        Path path = Paths.get(URI.create("file:///foo/bar/Main.java"));
//        System.out.print(path.getName(200));

//        Path p = Paths.get("/foo/bar/Main.java");
//        for (Path e : p) {
//            System.out.println(e);
//        }

        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Answer solver = new Answer();
        solver.solve(in, out);
        out.close();
    }
}

class Answer {
    private final int INF = (int) (1e9 + 7);
    private final int MOD = (int) (1e9 + 7);
    private final int MOD1 = (int) (1e6 + 3);
    private final long INF_LONG = (long) (1e18 + 1);
    private final double EPS = 1e-9;

    public void solve(InputReader in, PrintWriter out) throws IOException {
        int n = in.nextInt();
        int d = in.nextInt();

        long[] b = in.nextArrayLong(n);

        long ans = 0;

        for (int i = 1; i < n; i++) {
            long kol = 0;
            if (b[i] == b[i - 1]) {
                kol = 1;
            } else if (b[i] < b[i - 1]) {
                kol = (b[i - 1] - b[i]) / d;
                if ((b[i - 1] - b[i]) % d != 0) {
                    kol++;
                }
            }
            ans += kol;
            b[i] += 1L * kol * d;
        }

        out.println(ans);

//        for (int i = 0; i < n; i++) {
//            out.print(b[i] + " ");
//        }

    }
}

class InputReader {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream), 32768);
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

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

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

    public int[] nextArrayInt(int count) {
        int[] a = new int[count];
        for (int i = 0; i < count; i++) {
            a[i] = nextInt();
        }
        return a;
    }

    public long[] nextArrayLong(int count) {
        long[] a = new long[count];
        for (int i = 0; i < count; i++) {
            a[i] = nextLong();
        }
        return a;
    }
}


import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastScanner input = new FastScanner();

		int N = input.nextInt();
		int d = input.nextInt();

		long[] arr = new long[N];
		for (int i = 0; i < N; i++) arr[i] = input.nextLong();
		int count = 0;
		for (int i = 1; i < N; i++) {
			while (arr[i] <= arr[i - 1]) {
				arr[i] += d;
				count++;
			}
		}
		System.out.println(count);
	}

	// https://github.com/detel/Faster-InputOutput-Implementations/blob/master/FastScanner.java
	// Fast I/O
	static class FastScanner {

		BufferedReader br;
		StringTokenizer st;

		public FastScanner(String s) {
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		public FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

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

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


import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastScanner input = new FastScanner();

		int N = input.nextInt();
		int d = input.nextInt();

		long[] arr = new long[N];
		for (int i = 0; i < N; i++) arr[i] = input.nextLong();
		int count = 0;
		for (int i = 1; i < N; i++) {
			if (arr[i - 1] >= arr[i]) {
				int change = (int) Math.ceil((arr[i - 1] - arr[i] + 1 * 1.00) / d);
				arr[i] += change * d;
				count += change;
			}
		}
		System.out.println(count);
	}

	// https://github.com/detel/Faster-InputOutput-Implementations/blob/master/FastScanner.java
	// Fast I/O
	static class FastScanner {

		BufferedReader br;
		StringTokenizer st;

		public FastScanner(String s) {
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		public FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

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

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


import java.util.Scanner;

public class A11 {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int i,k=0;
		int n=scan.nextInt();
		int d=scan.nextInt();
		scan.nextLine();
		int []a=new int[n];
		for(i=0;i<n;i++)
			a[i]=scan.nextInt();
		for(i=1;i<n;i++)
			{
			if (a[i]<=a[i-1])

					{
				while (a[i]<=a[i-1])
				{
					a[i] *=d;
					k++;
				}
					}
			}

		System.out.println(k);
	}
}


import java.util.Scanner;
public class A11 {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int i;
		int k=0,k1=0;
		int a,b;
		int n=scan.nextInt();
		int d=scan.nextInt();
		scan.nextLine();
		a=scan.nextInt();
		for(i=1;i<n;i++)
		{
			k=0;
			b=scan.nextInt();
					if (b<=a)
					{
						while (b<=a)
						{
							b=b+d;
							k++;}
						k1=k+k1;
						}
			a=b;
		}
		System.out.println(k1);
	}
}


import java.util.Scanner;
public class A11 {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int i;
		int k=0,k1=0;
		int n=scan.nextInt();
		int d=scan.nextInt();
		scan.nextLine();
		int []a=new int[n];
		for(i=0;i<n;i++)
		a[i]=scan.nextInt();
		for(i=1;i<n;i++)
		{
					if (a[i]<=a[i-1])
						{
						k=(a[i-1]-a[i])/d+1;
						a[i]+=d*k;
						k1+=k;
						}
		}
		System.out.println(k1);
	}
}


import java.util.Scanner;

public class A11 {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int i;
		int k=0,k1=0;
		int a,b;
		int n=scan.nextInt();
		int d=scan.nextInt();
		scan.nextLine();
		a=scan.nextInt();
		for(i=1;i<n;i++)
		{
			b=scan.nextInt();
					if (b<=a)
					{
						k=(a-b)/d+1;
						b=b+d*k;
					}
					k1=k+k1;
			a=b;

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


import java.util.Scanner;

public class A11 {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int i,a,b,k=0;
		int n=scan.nextInt();
		int d=scan.nextInt();
		scan.nextLine();
		a=scan.nextInt();
		for(i=1;i<n;i++)
		{

			b=scan.nextInt();
					while (b<=a)
					{
						b +=d;
						k++;
					}
			a=b;

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


import java.util.Scanner;

public class A11 {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int i,k=0;
		int n=scan.nextInt();
		int d=scan.nextInt();
		scan.nextLine();
		int []a=new int[n];
			a[0]=scan.nextInt();
			for(i=1;i<n;i++)
			{
				a[i]=scan.nextInt();

					while (a[i]<=a[i-1])
					{
						a[i] +=d;
						k++;
					}

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


import java.util.Scanner;

public class A11 {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int i,k=0;
		int n=scan.nextInt();
		int d=scan.nextInt();
		scan.nextLine();
		int []a=new int[n];
		for(i=0;i<n;i++)
			a[i]=scan.nextInt();
		for(i=1;i<n;i++)
			{
			if (a[i]<=a[i-1])
				{
				while (a[i]<=a[i-1])
				{
					a[i] +=d;
					k++;
				}
				}
			}

		System.out.println(k);
	}
}


import java.util.Scanner;

public class A11 {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int i,k=0;
		int n=scan.nextInt();
		int d=scan.nextInt();
		scan.nextLine();
		int []a=new int[n];
			a[0]=scan.nextInt();
			for(i=1;i<n;i++)
			{
				a[i]=scan.nextInt();
				if (a[i]<=a[i-1])
				{
					while (a[i]<=a[i-1])
					{
						a[i] +=d;
						k++;
					}
				}

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


import java.util.Scanner;

public class A11 {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int i,k=0;
		long a,b;
		int n=scan.nextInt();
		int d=scan.nextInt();
		scan.nextLine();
		a=scan.nextInt();
		for(i=1;i<n;i++)
		{
			b=scan.nextInt();
					while (b<=a)
					{
						b +=d;
						k++;
					}
			a=b;

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


/*
 */

package javaapplication141;

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

/**
 *
 * @author Haya
 */
public class JavaApplication141 {

    public static void main(String[] args) {

        FastReader in = new FastReader();

        int n = in.nextInt();
        int dif = in.nextInt();

        int nums[] = new int[n];

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

        int count = 0;

        for (int i = 1; i < n; i++) {

            if (nums[i-1]<nums[i])
                continue;

            int toadd = (int) Math.ceil((nums[i-1]-nums[i]+1)/(dif*1.0));

            count += toadd;
            nums[i]+=toadd*dif;
        }

        System.out.println(count);

    }

    public static class FastReader {

        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String string = "";
            try {
                string = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return string;
        }

    }

}


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

/**
 *
 * @author Haya
 */
public class JavaApplication141 {

    public static void main(String[] args) {

        FastReader in = new FastReader();

        int n = in.nextInt();
        int dif = in.nextInt();

        int nums[] = new int[n];

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

        int cur = nums[0];
        int next = nums[1];

        int count = 0;

        for (int i = 0; i < n-1; i++) {
            cur = nums[i];
            next = nums[i+1];

            if (next <= cur){

                int toadd = Math.max(next,cur)-Math.min(next,cur)+1;

                if (toadd < dif)
                    count++;
                else{
                    count += (int)(toadd/dif);
                }
                nums[i+1] += (count*dif);

            }

        }

        System.out.println(count);

    }

    public static class FastReader {

        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String string = "";
            try {
                string = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return string;
        }

    }

}


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

/**
 *
 * @author Haya
 */
public class JavaApplication141 {

    public static void main(String[] args) {

        FastReader in = new FastReader();

        int n = in.nextInt();
        int dif = in.nextInt();

        int nums[] = new int[n];

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

        int count = 0;

        for (int i = 1; i < n; i++) {

            if (nums[i-1]<nums[i])
                continue;

            int toadd = (int) Math.ceil((nums[i-1]-nums[i]+1)/(dif*1.0));

            count += toadd;
            nums[i]+=toadd*dif;
        }

        System.out.println(count);

    }

    public static class FastReader {

        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String string = "";
            try {
                string = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return string;
        }

    }

}


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

/**
 *
 * @author Haya
 */
public class JavaApplication141 {

    public static void main(String[] args) {

        FastReader in = new FastReader();

        int n = in.nextInt();
        int dif = in.nextInt();

        int nums[] = new int[n];

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

        int count = 0;

        for (int i = 1; i < n; i++) {

            if (nums[i-1]<nums[i])
                continue;

            int toadd = (int) Math.ceil((nums[i-1]-nums[i]+1)/(dif*1.0));

            count += toadd;
            nums[i]=toadd*dif;
        }

        System.out.println(count);

    }

    public static class FastReader {

        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String string = "";
            try {
                string = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return string;
        }

    }

}


import java.util.*;

public class IncreasingSequence
{
	public static void main(String args[])
	{
		int n,d,count=0;
		Scanner s=new Scanner(System.in);
		n=s.nextInt();
		d=s.nextInt();
		int[] a=new int[n];
		for(int i=0;i<n;i++)
		{
			a[i]=s.nextInt();
		}
		int i=0;
		while(i<n-1)
		{
			if(a[i]>a[i+1])
			{
				//++count;
				count=count+((a[i]-a[i+1])/d)+1;
				a[i+1]=a[i+1]+(count*d);
				++i;
			}
			else if(a[i]==a[i+1])
			{
				++count;
				a[i+1]=a[i+1]+d;
				++i;
			}
			else
			{
				++i;
			}
		}
		System.out.print(count);
	}
}


import java.util.*;

public class IncreasingSequence
{
	public static void main(String args[])
	{
		int n,d,count=0;
		Scanner s=new Scanner(System.in);
		n=s.nextInt();
		d=s.nextInt();
		int[] a=new int[n];
		for(int i=0;i<n;i++)
		{
			a[i]=s.nextInt();
		}
		int i=0;
		//for(int i=1;i<=n;i++)
		while(i<n-1)
		{
			if(a[i]>=a[i+1])
			{
				++count;
				a[i+1]=a[i+1]+d;
			}
			else
			{
				++i;
			}
		}
		System.out.print(count);
	}
}


import java.util.*;

public class IncreasingSequence
{
	public static void main(String args[])
	{
		int n,d,count=0;
		Scanner s=new Scanner(System.in);
		n=s.nextInt();
		d=s.nextInt();
		int[] a=new int[10000000];
		for(int i=0;i<n;i++)
		{
			a[i]=s.nextInt();
		}
		int i=0;
		//for(int i=1;i<=n;i++)
		while(i<n-1)
		{
			if(a[i]>=a[i+1])
			{
				++count;
				a[i+1]=a[i+1]+d;
			}
			else if(a[i]<a[i+1])
			{
				++i;
			}
		}
		System.out.print(count);
	}
}


import java.util.*;

public class IncreasingSequence
{
	public static void main(String args[])
	{
		int n,d,count=0;
		Scanner s=new Scanner(System.in);
		n=s.nextInt();
		d=s.nextInt();
		int[] a=new int[n];
		for(int i=0;i<n;i++)
		{
			a[i]=s.nextInt();
		}
		int i=0;
		while(i<n-1)
		{
			if(a[i]>=a[i+1])
			{
				++count;
				a[i+1]=a[i+1]+d;
			}
			else
			{
				++i;
			}
		}
		System.out.print(count);
	}
}


#include <iostream>
#include <deque>
#define pii pair<int, int>
#define mk make_pair
#define f first
#define s second
#define MAX 100005
using namespace std;

int n, c, a[MAX], b[MAX], d[MAX];
long long sum, res;
deque<pii> q;

int main() {
    cin >> n >> c;
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
        sum += (long long)a[i];
    }

    q.push_back(mk(a[0], 0));
    for(int i = 1; i < c; ++i) {
        while(!q.empty() && q.back().f >= a[i])
            q.pop_back();
        q.push_back(mk(a[i], i));
    }
    b[c - 1] = q.front().f;

    for(int i = c; i < n; ++i) {
        if(q.front().s == i - c)
            q.pop_front();
        while(!q.empty() && q.back().f >= a[i])
            q.pop_back();
        q.push_back(mk(a[i], i));
        b[i] = q.front().f;
    }

    d[c - 1] = b[c - 1];
    for(int i = c; i < n; ++i) {
        d[i] = max(d[i - c] + b[i], d[i - 1]);
    }

    cout << sum - d[n - 1] << "\n";
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long lol;
lol n,m,f[100005],a[100005],q[100005],head,tail=-1,sum;
int main(){
  lol i,j;
  scanf("%lld%lld",&n,&m);
  for(i=1;i<=n;i++)scanf("%lld",&a[i]),sum+=a[i];
  for(i=1;i<=n;i++){
    while(head<=tail&&i-m>=q[head])head++;
    while(head<=tail&&a[q[tail]]>a[i])tail--;
    q[++tail]=i;
    f[i]=f[i-1];
    if(i>=m)f[i]=max(f[i],f[i-m]+a[q[head]]);
  }
  printf("%lld\n",sum-f[n]);
  return 0;
}


#include<cstdio>
#include<iostream>
using namespace std;
int n,c;
int a[100010];
long long f[100010],sum;
struct tree{
	int l,r,minn;
}tr[100010];
void update(int i){tr[i].minn=min(tr[i<<1].minn,tr[i<<1|1].minn);}
void build(int i,int l,int r)
{
	tr[i].l=l,tr[i].r=r;
	if (l==r) {tr[i].minn=a[l];return;}
	int mid=l+r>>1;
	build(i<<1,l,mid);build(i<<1|1,mid+1,r);
	update(i);
}
int query(int i,int l,int r)
{
	int L=tr[i].l,R=tr[i].r;
	if (L>r||l>R) return 1e9;
	if (l<=L&&R<=r) return tr[i].minn;
	int ans=1e9;
	ans=min(ans,query(i<<1,l,r));
	ans=min(ans,query(i<<1|1,l,r));
	return ans;
}
int main()
{
	scanf("%d%d",&n,&c);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]),sum+=a[i];
	build(1,1,n);
	for (int i=c;i<=n;i++)
		f[i]=f[i-1],f[i]=max(f[i],f[i-c]+query(1,i-c+1,i));
	printf("%d",sum-f[n]);
}


#include<cstdio>
#include<iostream>
using namespace std;
int n,c;
int a[100010];
long long f[100010],sum;
struct tree{
	int l,r,minn;
}tr[400010];
void update(int i){tr[i].minn=min(tr[i<<1].minn,tr[i<<1|1].minn);}
void build(int i,int l,int r)
{
	tr[i].l=l,tr[i].r=r;
	if (l==r) {tr[i].minn=a[l];return;}
	int mid=l+r>>1;
	build(i<<1,l,mid);build(i<<1|1,mid+1,r);
	update(i);
}
int query(int i,int l,int r)
{
	int L=tr[i].l,R=tr[i].r;
	if (L>r||l>R) return 1e9;
	if (l<=L&&R<=r) return tr[i].minn;
	int ans=1e9;
	ans=min(ans,query(i<<1,l,r));
	ans=min(ans,query(i<<1|1,l,r));
	return ans;
}
int main()
{
	scanf("%d%d",&n,&c);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]),sum+=a[i];
	build(1,1,n);
	for (int i=c;i<=n;i++)
		f[i]=f[i-1],f[i]=max(f[i],f[i-c]+query(1,i-c+1,i));
	printf("%lld",sum-f[n]);
}


#include<cstdio>
#include<iostream>
using namespace std;
int n,c;
int a[100010];
long long f[100010],sum;
struct tree{
	int l,r,minn;
}tr[100010];
void update(int i){tr[i].minn=min(tr[i<<1].minn,tr[i<<1|1].minn);}
void build(int i,int l,int r)
{
	tr[i].l=l,tr[i].r=r;
	if (l==r) {tr[i].minn=a[l];return;}
	int mid=l+r>>1;
	build(i<<1,l,mid);build(i<<1|1,mid+1,r);
	update(i);
}
int query(int i,int l,int r)
{
	int L=tr[i].l,R=tr[i].r;
	if (L>r||l>R) return 1e9;
	if (l<=L&&R<=r) return tr[i].minn;
	int ans=1e9;
	ans=min(ans,query(i<<1,l,r));
	ans=min(ans,query(i<<1|1,l,r));
	return ans;
}
int main()
{
	scanf("%d%d",&n,&c);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]),sum+=a[i];
	build(1,1,n);
	for (int i=c;i<=n;i++)
		f[i]=f[i-1],f[i]=max(f[i],f[i-c]+query(1,i-c+1,i));
	printf("%lld",sum-f[n]);
}


#include<bits/stdc++.h>

using namespace std;

int const maxn=100003;

#define forab(i,a,b) for(int i=a;i<=b;i++)

int n,c,a[maxn],q[maxn];
long long f[maxn];

int inline read(){
	int x=0,w=0;char ch=0;
	while (ch<'0' || ch>'9') w|=ch=='-',ch=getchar();
	while (ch>='0' && ch<='9') x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return w? -x:x;
}

int main(){
	n=read();
	c=read();
	long long sum=0;
	forab(i,1,n) a[i]=read(),sum+=a[i];
	if(c==1){
		cout<<0<<endl;
		return 0;
	}
	int st=0,ed=-1;
	forab(i,1,c-1) {
		while (st<=ed && a[q[ed]]>=a[i]) ed--;
		q[++ed]=i;
	}
	forab(i,c,n){
		int k=1<<30;
		while (st<=ed && q[st]<i-c+1) st++;
		while (st<=ed && a[q[ed]]>=a[i]) ed--;
		q[++ed]=i;
		f[i]=max(f[i-1],f[i-c]+a[q[st]]);
	}
	printf("%lld\n",sum-f[n]);
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

int const maxn=100003;

#define forab(i,a,b) for(int i=a;i<=b;i++)
#define forba(i,a,b) for(int i=a;i>=b;i--)
int n,c,a[maxn];
long long f[maxn];

int inline read(){
	int x=0,w=0;char ch=0;
	while (ch<'0' || ch>'9') w|=ch=='-',ch=getchar();
	while (ch>='0' && ch<='9') x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return w? -x:x;
}

int main(){
	n=read();
	c=read();
	long long sum=0;
	forab(i,1,n) a[i]=read(),sum+=a[i];
	if(c==1){
		cout<<0<<endl;
		return 0;
	}
	forab(i,c,n){
		int k=1<<30;
		forba(j,i,i-c+1) k=min(k,a[j]);
		f[i]=max(f[i-1],f[i-c]+k);
	}
	printf("%lld\n",sum-f[n]);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1e5 + 5;
const int LOGN = 20;

int n, c;
int a[MAXN];
int b[MAXN][LOGN];
long long dp[MAXN];
long long s[MAXN];

int query(int l, int r) {
    int k = log2(r - l + 1);
    return min(b[l][k], b[r - (1 << k) + 1][k]);
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE
    scanf("%d%d", &n, &c);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", a + i);
        s[i] = s[i - 1] + a[i];
    }
    for (int i = n; i >= 1; --i) {
        b[i][0] = a[i];
        for (int j = 1; i + (1 << j) - 1 <= n; ++j) {
            b[i][j] = min(b[i][j - 1], b[i + (1 << j - 1)][j - 1]);
        }
    }
    for (int i = 1; i < c; ++i) {
        dp[i] = s[i];
    }
    for (int i = c; i <= n; ++i) {
        dp[i] = min(dp[i - 1] + a[i], dp[i - c] + s[i] - s[i - c] - query(i - c + 1, i));
    }
    printf("%I64d", dp[n]);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1e5 + 5;
const int LOGN = 20;

int n, c;
int a[MAXN];
int b[MAXN][LOGN];
long long dp[MAXN];
long long s[MAXN];

int query(int l, int r) {
    int k = log2(r - l + 1);
    return min(b[l][k], b[r - (1 << k) + 1][k]);
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE
    scanf("%d%d", &n, &c);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", a + i);
        s[i] = s[i - 1] + a[i];
    }
    for (int i = n; i >= 1; --i) {
        b[i][0] = a[i];
        for (int j = 1; i + (1 << j) - 1 <= n; ++j) {
            b[i][j] = min(b[i][j - 1], b[i + (1 << j - 1)][j - 1]);
        }
    }
    for (int i = 1; i < c; ++i) {
        dp[i] = s[i];
    }
    for (int i = c; i <= n; ++i) {
        dp[i] = min(dp[i - 1], dp[i - c] + s[i] - s[i - c] - query(i - c + 1, i));
    }
    long long ans = 1e18;
    for (int i = max(n - c + 1, 1); i <= n; ++i) {
        ans = min(ans, dp[i] + s[n] - s[i]);
    }
    printf("%I64d", ans);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1e5 + 5;
const int LOGN = 20;

int n, c;
int a[MAXN];
int b[MAXN][LOGN];
long long e[MAXN][LOGN];
long long f[MAXN];
long long g[MAXN];
long long s[MAXN];

int query(int l, int r) {
    int k = log2(r - l + 1);
    return min(b[l][k], b[r - (1 << k) + 1][k]);
}

long long query1(int l, int r) {
    int k = log2(r - l + 1);
    return max(e[r][k], e[l + (1 << k) - 1][k]);
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE
    scanf("%d%d", &n, &c);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", a + i);
        s[i] = s[i - 1] + a[i];
    }
    for (int i = n; i >= 1; --i) {
        b[i][0] = a[i];
        for (int j = 1; i + (1 << j) - 1 <= n; ++j) {
            b[i][j] = min(b[i][j - 1], b[i + (1 << j - 1)][j - 1]);
        }
    }
    for (int i = 1; i <= n; ++i) {
        if (i >= c) {
            f[i] = g[i - c] + query(i - c + 1, i);
        }
        else {
            f[i] = -1e18;
        }
        e[i][0] = f[i];
        for (int j = 1; i - (1 << j) + 1 >= 0; ++j) {
            e[i][j] = max(e[i][j - 1], e[i - (1 << j - 1)][j - 1]);
        }
        g[i] = query1(max(0, i - c + 1), i);
    }
    printf("%I64d", s[n] - g[n]);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1e5 + 5;
const int LOGN = 20;

int n, c;
int a[MAXN];
int b[MAXN][LOGN];
long long dp[MAXN];
long long s[MAXN];

int query(int l, int r) {
    int k = log2(r - l + 1);
    return min(b[l][k], b[r - (1 << k) + 1][k]);
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE
    scanf("%d%d", &n, &c);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", a + i);
        s[i] = s[i - 1] + a[i];
    }
    for (int i = n; i >= 1; --i) {
        b[i][0] = a[i];
        for (int j = 1; i + (1 << j) - 1 <= n; ++j) {
            b[i][j] = min(b[i][j - 1], b[i + (1 << j - 1)][j - 1]);
        }
    }
    for (int i = 1; i < c; ++i) {
        dp[i] = s[i];
    }
    for (int i = c; i <= n; ++i) {
        dp[i] = dp[i - c] + s[i] - s[i - c] - query(i - c + 1, i);
    }
    long long ans = 1e18;
    for (int i = max(n - c + 1, 1); i <= n; ++i) {
        ans = min(ans, dp[i] + s[n] - s[i]);
    }
    printf("%I64d", ans);
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1e5 + 5;
const int LOGN = 20;

int n, c;
int a[MAXN];
int b[MAXN][LOGN];
long long e[MAXN][LOGN];
long long f[MAXN];
long long g[MAXN];
long long s[MAXN];

int query(int l, int r) {
    int k = log2(r - l + 1);
    return min(b[l][k], b[r - (1 << k) + 1][k]);
}

long long query1(int l, int r) {
    int k = log2(r - l + 1);
    return max(e[r][k], e[l + (1 << k) - 1][k]);
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE
    scanf("%d%d", &n, &c);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", a + i);
        s[i] = s[i - 1] + a[i];
    }
    for (int i = n; i >= 1; --i) {
        b[i][0] = a[i];
        for (int j = 1; i + (1 << j) - 1 <= n; ++j) {
            b[i][j] = min(b[i][j - 1], b[i + (1 << j - 1)][j - 1]);
        }
    }
    for (int i = 1; i <= n; ++i) {
        if (i >= c) {
            f[i] = g[i - c] + query(i - c + 1, i);
        }
        else {
            f[i] = -1e18;
        }
        e[i][0] = f[i];
        for (int j = 1; i - (1 << j) + 1 >= 0; ++j) {
            e[i][j] = max(e[i][j - 1], e[i - (1 << j - 1)][j - 1]);
        }
        g[i] = query1(i - c + 1, i);
    }
    printf("%I64d", s[n] - g[n]);
    return 0;
}


#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<ctype.h>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<math.h>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<stdio.h>
#include<stdlib.h>
#include<streambuf>
#include<string.h>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
using namespace std;
inline void gtmx(int &a,int b){
	if (a<b) a=b;
}
inline void gtmn(int &a,int b){
	if (a>b) a=b;
}
typedef long long LL;
int a[100010];
LL tot;
multiset<int> ain;
LL dp[100010];
int main(void){
	int n,m;
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;++i){
		scanf("%d",&a[i]);
		dp[i]=dp[i-1]+a[i];
	}
	for (int i=1;i<m;++i){
		ain.insert(a[i]);
		tot+=a[i];
	}
	for (int i=0;i<n;++i){
		if (i+m>n){
			dp[i+1]=min(dp[i+1],dp[i]+a[i+1]);
			continue;
		}
		if (i){
			tot-=a[i];
			tot+=a[i+m];
			ain.erase(ain.find(a[i]));
			ain.insert(a[i+m]);
		}
		else{
			tot+=a[i+m];
			ain.insert(a[i+m]);
		}
		dp[i+m]=min(dp[i+m],dp[i]+tot-*ain.begin());
	}
	printf("%I64d",dp[n]);
	return 0;
}


#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<ctype.h>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<math.h>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<stdio.h>
#include<stdlib.h>
#include<streambuf>
#include<string.h>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
using namespace std;
inline void gtmx(int &a,int b){
	if (a<b) a=b;
}
inline void gtmn(int &a,int b){
	if (a>b) a=b;
}
typedef long long LL;
int a[100010];
LL tot;
multiset<int> ain;
LL dp[100010];
int main(void){
	int n,m;
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;++i){
		scanf("%d",&a[i]);
		dp[i]=dp[i-1]+a[i];
	}
	for (int i=1;i<m;++i){
		ain.insert(a[i]);
		tot+=a[i];
	}
	for (int i=0;i<n;++i){
		dp[i+1]=min(dp[i+1],dp[i]+a[i+1]);
		if (i+m>n){
			continue;
		}
		if (i){
			tot-=a[i];
			tot+=a[i+m];
			ain.erase(ain.find(a[i]));
			ain.insert(a[i+m]);
		}
		else{
			tot+=a[i+m];
			ain.insert(a[i+m]);
		}
		dp[i+m]=min(dp[i+m],dp[i]+tot-*ain.begin());
	}
	printf("%I64d",dp[n]);
	return 0;
}


/**
 *　　　　　　　　┏┓　　 　┏┓
 * 　　　　　　　┏┛┗━━━━━━━┛┗━━━┓
 * 　　　　　　　┃　　　　　　　┃
 * 　　　　　　　┃　　　━　　 　┃
 * 　　　　　　　┃　＞　　　＜　┃
 * 　　　　　　　┃　　　　　　　┃
 * 　　　　　　　┃...　⌒　... 　┃
 * 　　　　　　　┃　　　　　　　┃
 * 　　　　　　　┗━┓　　　┏━┛
 * 　　　　　　　　　┃　　　┃　Code is far away from bug with the animal protecting
 * 　　　　　　　　　┃　　　┃   神兽保佑,代码无bug
 * 　　　　　　　　　┃　　　┃
 * 　　　　　　　　　┃　　　┃
 * 　　　　　　　　　┃　　　┃
 * 　　　　　　　　　┃　　　┃
 * 　　　　　　　　　┃　　　┗━━━┓
 * 　　　　　　　　　┃　　　　　　　┣┓
 * 　　　　　　　　　┃　　　　　　　┏┛
 * 　　　　　　　　　┗┓┓┏━┳┓┏┛
 * 　　　　　　　　　　┃┫┫　┃┫┫
 * 　　　　　　　　　　┗┻┛　┗┻┛
 */
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<queue>
#include<cmath>
#include<map>
#include<stack>
#define inc(i,l,r) for(int i=l;i<=r;i++)
#define dec(i,l,r) for(int i=l;i>=r;i--)
#define link(x) for(edge *j=h[x];j;j=j->next)
#define mem(a) memset(a,0,sizeof(a))
#define ll long long
#define eps 1e-12
#define succ(x) (1<<x)
#define lowbit(x) (x&(-x))
#define sqr(x) ((x)*(x))
#define mid (x+y>>1)
#define NM 200005
#define nm 105
#define pi 3.1415926535897931
using namespace std;
const ll inf=1000000000;
ll read(){
    ll x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
    while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
    return f*x;
}

ll a[NM],c[NM],d[NM],ans,s;
ll n,k;

struct tmp{
	int num;
	bool operator<(const tmp&o)const{return a[num]>a[o.num];}
}b[NM];
priority_queue<tmp>q;
int main(){
	n=read();k=read();
	inc(i,1,n)b[i].num=i;
	inc(i,1,n)a[i]=read();
	inc(i,1,n)s+=a[i];
	inc(i,1,k-1)q.push(b[i]);
	inc(i,k,n){
		q.push(b[i]);
		tmp t=q.top();
		while(t.num<=i-k)q.pop(),t=q.top();
		c[i]=a[t.num];
	}
	inc(i,k,n)d[i]=max(d[i-1],d[i-k]+c[i]);
	inc(i,1,n)ans=max(ans,d[i]);
	printf("%I64d\n",s-ans);
	return 0;
}


/**
 *　　　　　　　　┏┓　　 　┏┓
 * 　　　　　　　┏┛┗━━━━━━━┛┗━━━┓
 * 　　　　　　　┃　　　　　　　┃
 * 　　　　　　　┃　　　━　　 　┃
 * 　　　　　　　┃　＞　　　＜　┃
 * 　　　　　　　┃　　　　　　　┃
 * 　　　　　　　┃...　⌒　... 　┃
 * 　　　　　　　┃　　　　　　　┃
 * 　　　　　　　┗━┓　　　┏━┛
 * 　　　　　　　　　┃　　　┃　Code is far away from bug with the animal protecting
 * 　　　　　　　　　┃　　　┃   神兽保佑,代码无bug
 * 　　　　　　　　　┃　　　┃
 * 　　　　　　　　　┃　　　┃
 * 　　　　　　　　　┃　　　┃
 * 　　　　　　　　　┃　　　┃
 * 　　　　　　　　　┃　　　┗━━━┓
 * 　　　　　　　　　┃　　　　　　　┣┓
 * 　　　　　　　　　┃　　　　　　　┏┛
 * 　　　　　　　　　┗┓┓┏━┳┓┏┛
 * 　　　　　　　　　　┃┫┫　┃┫┫
 * 　　　　　　　　　　┗┻┛　┗┻┛
 */
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<queue>
#include<cmath>
#include<map>
#include<stack>
#define inc(i,l,r) for(int i=l;i<=r;i++)
#define dec(i,l,r) for(int i=l;i>=r;i--)
#define link(x) for(edge *j=h[x];j;j=j->next)
#define mem(a) memset(a,0,sizeof(a))
#define ll long long
#define eps 1e-12
#define succ(x) (1<<x)
#define lowbit(x) (x&(-x))
#define sqr(x) ((x)*(x))
#define mid (x+y>>1)
#define NM 100005
#define nm 105
#define pi 3.1415926535897931
using namespace std;
const ll inf=1000000000;
ll read(){
    ll x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
    while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
    return f*x;
}

ll a[NM],c[NM],d[NM],ans,s;
int n,k;

struct tmp{
	int i;
	bool operator<(const tmp&o)const{return a[i]>a[o.i];}
}b[NM];
priority_queue<tmp>q;
int main(){
	n=read();k=read();
	inc(i,1,n)b[i].i=i;
	inc(i,1,n)a[i]=read();
	inc(i,1,n)s+=a[i];
	inc(i,1,k-1)q.push(b[i]);
	inc(i,k,n){
		q.push(b[i]);
		tmp t=q.top();
		while(t.i<=i-k)q.pop(),t=q.top();
		c[i]=a[t.i];
	}
	inc(i,k,n)d[i]=max(d[i],d[i-k]+c[i]);
	inc(i,1,n)ans=max(ans,d[i]);
	printf("%I64d\n",s-ans);
	return 0;
}


/**
 *　　　　　　　　┏┓　　 　┏┓
 * 　　　　　　　┏┛┗━━━━━━━┛┗━━━┓
 * 　　　　　　　┃　　　　　　　┃
 * 　　　　　　　┃　　　━　　 　┃
 * 　　　　　　　┃　＞　　　＜　┃
 * 　　　　　　　┃　　　　　　　┃
 * 　　　　　　　┃...　⌒　... 　┃
 * 　　　　　　　┃　　　　　　　┃
 * 　　　　　　　┗━┓　　　┏━┛
 * 　　　　　　　　　┃　　　┃　Code is far away from bug with the animal protecting
 * 　　　　　　　　　┃　　　┃   神兽保佑,代码无bug
 * 　　　　　　　　　┃　　　┃
 * 　　　　　　　　　┃　　　┃
 * 　　　　　　　　　┃　　　┃
 * 　　　　　　　　　┃　　　┃
 * 　　　　　　　　　┃　　　┗━━━┓
 * 　　　　　　　　　┃　　　　　　　┣┓
 * 　　　　　　　　　┃　　　　　　　┏┛
 * 　　　　　　　　　┗┓┓┏━┳┓┏┛
 * 　　　　　　　　　　┃┫┫　┃┫┫
 * 　　　　　　　　　　┗┻┛　┗┻┛
 */
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<queue>
#include<cmath>
#include<map>
#include<stack>
#define inc(i,l,r) for(int i=l;i<=r;i++)
#define dec(i,l,r) for(int i=l;i>=r;i--)
#define link(x) for(edge *j=h[x];j;j=j->next)
#define mem(a) memset(a,0,sizeof(a))
#define ll long long
#define eps 1e-12
#define succ(x) (1<<x)
#define lowbit(x) (x&(-x))
#define sqr(x) ((x)*(x))
#define mid (x+y>>1)
#define NM 200005
#define nm 105
#define pi 3.1415926535897931
using namespace std;
const ll inf=1000000000;
ll read(){
    ll x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
    while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
    return f*x;
}

ll a[NM],c[NM],d[NM],ans,s;
ll n,k;

struct tmp{
	int num;
	bool operator<(const tmp&o)const{return a[num]>a[o.num];}
}b[NM];
priority_queue<tmp>q;
int main(){
	n=read();k=read();
	inc(i,1,n)b[i].num=i;
	inc(i,1,n)a[i]=read();
	inc(i,1,n)s+=a[i];
	inc(i,1,k-1)q.push(b[i]);
	inc(i,k,n){
		q.push(b[i]);
		tmp t=q.top();
		while(t.num<=i-k)q.pop(),t=q.top();
		c[i]=a[t.num];
	}
	inc(i,k,n)d[i]=max(d[i],d[i-k]+c[i]);
	inc(i,1,n)ans=max(ans,d[i]);
	printf("%I64d\n",s-ans);
	return 0;
}


/**
 *　　　　　　　　┏┓　　 　┏┓
 * 　　　　　　　┏┛┗━━━━━━━┛┗━━━┓
 * 　　　　　　　┃　　　　　　　┃
 * 　　　　　　　┃　　　━　　 　┃
 * 　　　　　　　┃　＞　　　＜　┃
 * 　　　　　　　┃　　　　　　　┃
 * 　　　　　　　┃...　⌒　... 　┃
 * 　　　　　　　┃　　　　　　　┃
 * 　　　　　　　┗━┓　　　┏━┛
 * 　　　　　　　　　┃　　　┃　Code is far away from bug with the animal protecting
 * 　　　　　　　　　┃　　　┃   神兽保佑,代码无bug
 * 　　　　　　　　　┃　　　┃
 * 　　　　　　　　　┃　　　┃
 * 　　　　　　　　　┃　　　┃
 * 　　　　　　　　　┃　　　┃
 * 　　　　　　　　　┃　　　┗━━━┓
 * 　　　　　　　　　┃　　　　　　　┣┓
 * 　　　　　　　　　┃　　　　　　　┏┛
 * 　　　　　　　　　┗┓┓┏━┳┓┏┛
 * 　　　　　　　　　　┃┫┫　┃┫┫
 * 　　　　　　　　　　┗┻┛　┗┻┛
 */
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<queue>
#include<cmath>
#include<map>
#include<stack>
#define inc(i,l,r) for(int i=l;i<=r;i++)
#define dec(i,l,r) for(int i=l;i>=r;i--)
#define link(x) for(edge *j=h[x];j;j=j->next)
#define mem(a) memset(a,0,sizeof(a))
#define ll long long
#define eps 1e-12
#define succ(x) (1<<x)
#define lowbit(x) (x&(-x))
#define sqr(x) ((x)*(x))
#define mid (x+y>>1)
#define NM 200005
#define nm 105
#define pi 3.1415926535897931
using namespace std;
const ll inf=1000000000;
ll read(){
    ll x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
    while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
    return f*x;
}

ll a[NM],c[NM],d[NM],ans,s;
int n,k,q[NM],qh,qt;
int main(){
	n=read();k=read();k=min(k,n+1);
	inc(i,1,n)a[i]=read();
	inc(i,1,n)s+=a[i];
	q[qh=qt=1]=1;
	inc(i,2,k-1){while(a[i]<=a[q[qt]])qt--;q[++qt]=i;}
	inc(i,k,n){
		while(qh<=qt&&q[qh]<=i-k)qh++;
		while(qh<=qt&&a[i]<=a[q[qt]])qt--;
		q[++qt]=i;
		c[i]=a[q[qh]];
	}
	inc(i,k,n)d[i]=max(d[i-1],d[i-k]+c[i]);
	inc(i,1,n)ans=max(ans,d[i]);
	printf("%I64d\n",s-ans);
	return 0;
}