// Arup Guha
// 3/23/2024
// Solution to Spring 2024 COP 3503 Program 6 Part B: Maximum k-Smooth Subsequence Sum

import java.util.*;

public class subseqsum {

	public static void main(String[] args) {
	
		// Get basic input.
		Scanner stdin = new Scanner(System.in);
		int n = stdin.nextInt();
		int k = stdin.nextInt();
		
		// Get sequence.
		int[] seq = new int[n];
		for (int i=0; i<n; i++)	
			seq[i] = stdin.nextInt();
			
		// Set up DP arrays.
		long[] dp = new long[n];
		int[] prev = new int[n];
		
		// Answers for sequence of length 1.
		dp[0] = seq[0];
		prev[0] = -1;
		
		// Build the rest of the answers.
		for (int i=1; i<n; i++) {
		
			// Pretend we start with this as the first item.
			dp[i] = seq[i];
			prev[i] = -1;
			
			// Build off previous sequences that end at index j.
			for (int j=0; j<i; j++) {
				
				// Can't place index i right after index j so skip this.
				if (Math.abs(seq[j]-seq[i]) > k) continue;
				
				// If we build our current sequence by adding term i right after term j, this is our new sum.
				long tmp = dp[j] + seq[i];
				
				// Update if it's better than what we've seen before.
				if (tmp > dp[i]) {
					dp[i] = tmp;
					prev[i] = j;
				}
			}
		}
		
		// Find the best ending index.
		int besti = 0;
		for (int i=1; i<n; i++)
			if (dp[i] > dp[besti])
				besti = i;
				
		// This is the max sum.
		System.out.println(dp[besti]);
		
		// Store indexes here.
		ArrayList<Integer> idx = new ArrayList<Integer>();
		int cur = besti;
		
		// Build it backwards by following the previous array.
		while (cur != -1) {
			idx.add(cur);
			cur = prev[cur];
		}
		
		// Reverse before we print.
		Collections.reverse(idx);
		for (int i=0; i<idx.size(); i++)
			System.out.print( (idx.get(i)+1)+" ");
		System.out.println();
	}
}