Problem:
Score : 1000 points

Problem Statement

Snuke participated in a magic show.

A magician prepared N identical-looking boxes.
He put a treasure in one of the boxes, closed the boxes, shuffled them, and numbered them 1 through N.

Since the boxes are shuffled, now Snuke has no idea which box contains the treasure.
Snuke wins the game if he opens a box containing the treasure.
You may think that if Snuke opens all boxes at once, he can always win the game.
However, there are some tricks:

Snuke must open the boxes one by one. After he opens a box and checks the content of the box, he must close the box before opening the next box.

He is only allowed to open Box i at most a_i times.

The magician may secretly move the treasure from a closed box to another closed box, using some magic trick.
For simplicity, assume that the magician never moves the treasure while Snuke is opening some box.
However, he can move it at any other time (before Snuke opens the first box, or between he closes some box and opens the next box).

The magician can perform the magic trick at most K times.

Can Snuke always win the game, regardless of the initial position of the treasure and the movements of the magician?

Constraints

2 \leq N \leq 50

1 \leq K \leq 50

1 \leq a_i \leq 100

Input

Input is given from Standard Input in the following format:

N K
a_1 a_2 \cdots a_N

Output

If the answer is no, print a single -1.

Otherwise, print one possible move of Snuke in the following format:

Q
x_1 x_2 \cdots x_Q

It means that he opens boxes x_1, x_2, \cdots, x_Q in this order.

In case there are multiple possible solutions, you can output any.

Sample Input 1

2 1
5 5

Sample Output 1

7
1 1 2 1 2 2 1

If Snuke opens the boxes 7 times in the order 1 \rightarrow 1 \rightarrow 2 \rightarrow 1 \rightarrow 2 \rightarrow 2 \rightarrow 1, he can always find the treasure regardless of its initial position and the movements of the magician.

Sample Input 2

3 50
5 10 15

Sample Output 2

-1

Solution in Java8 (OpenJDK 1.8.0) (judge verdict: Wrong Answer)

import java.io.*;
import java.util.*;
import java.util.Map.Entry;

public class Main {
	
	final boolean isDebug = false;
	String fileName = "input.txt";
	FastScanner sc;
	//PrintWriter out;
	final int MOD = (int)1e9+7;
	final int INF = Integer.MAX_VALUE / 2;
	
	/* solve */
	void solve(){
		int N = sc.nextInt();
		int K = sc.nextInt();
		Pair[] p = new Pair[N];
		for(int i = 0; i < N; i++){
			p[i] = new Pair(sc.nextInt(), i+1);
		}
		Arrays.sort(p, (p1,p2)->p1.a-p2.a);
		
		StringBuilder ans = new StringBuilder();
		boolean isOk = true;
		int num = 0;
		
		if(N == 2){
			ans.append(p[1].index + " " + p[0].index);
			p[1].a--; p[0].a--;
			num += 2;
			for(int i = 0; i < K; i++){
				if(i % 2 == 0){
					ans.append(" " + p[1].index);
					p[1].a--;
					num++;
					if(p[1].a < 0){
						isOk = false;
						break;
					}
				}else{
					ans.append(" " + p[0].index);
					p[0].a--;
					num++;
					if(p[0].a < 0){
						isOk = false;
						break;
					}
				}
			}
			
			if(isOk){
				System.out.println(num);
				System.out.println(ans);
			}else{
				System.out.println(-1);
			}
			
			return;
		}
		
		for(int i = 0; i < K + 1; i++){
			for(int j = N - 1; j >= 2; j--){
				ans.append(p[j].index + " ");
				p[j].a--;
				num++;
			}
			if(i == 0){
				ans.append(p[1].index + " ");
				ans.append(p[0].index);
				p[1].a--; p[0].a--;
				num += 2;
			}else if(i % 2 == 1){
				ans.append(p[1].index);
				p[1].a--;
				num++;
			}else{
				ans.append(p[0].index);
				p[0].a--;
				num++;
			}
			ans.append((i == K) ? "\n" : " ");
		}
		
		for(int i = 0; i < N; i++) if(p[i].a < 0) isOk = false;
		
		if(isOk){
			System.out.println(num);
			System.out.print(ans);
		}else{
			System.out.println(-1);
		}
	}
	
	/* end solve */
	
	/* main */
	public static void main(String[] args) throws IOException {
		new Main().m();
	}
	
	void m() throws IOException {
		long S = System.currentTimeMillis();
		sc = (isDebug) ? new FastScanner(new FileInputStream(fileName)) : new FastScanner(System.in);
		//out = new PrintWriter(System.out);
		solve();
		//out.flush();
		long G = System.currentTimeMillis();
		if(isDebug){
			System.out.println("---Debug---");
			System.out.printf("%8d ms", (G-S));
		}
	}
	/* end main */
}
/* end Main */

class Pair{
	int a; int index;
	public Pair(int a, int index){
		this.a = a; this.index = index;
	}
}

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
    	if (hasNextByte()) return buffer[ptr++];
    	else return -1;
    }
    private static boolean isPrintableChar(int c){
    	return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
    	while(hasNextByte() && !isPrintableChar(buffer[ptr]))
    		ptr++; return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
    	return Double.parseDouble(next());
    }
}