Peter has a sequence of integers a1, a2, ..., an. Peter wants all numbers in the sequence to equal h. He can perform the operation of "adding one on the segment [l, r]": add one to all elements of the sequence with indices from l to r (inclusive). At that, Peter never chooses any element as the beginning of the segment twice. Similarly, Peter never chooses any element as the end of the segment twice. In other words, for any two segments [l1, r1] and [l2, r2], where Peter added one, the following inequalities hold: l1 ≠ l2 and r1 ≠ r2.

How many distinct ways are there to make all numbers in the sequence equal h? Print this number of ways modulo 1000000007 (109 + 7). Two ways are considered distinct if one of them has a segment that isn't in the other way.

Input

The first line contains two integers n, h (1 ≤ n, h ≤ 2000). The next line contains n integers a1, a2, ..., an (0 ≤ ai ≤ 2000).

Output

Print a single integer — the answer to the problem modulo 1000000007 (109 + 7).

Examples

Input

3 2
1 1 1


Output

4


Input

5 1
1 1 1 1 1


Output

1


Input

4 3
3 2 1 1


Output

0
import java.io.IOException;
import java.io.FilterInputStream;
import java.util.Iterator;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;
import java.io.BufferedInputStream;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Zyflair Griffane
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputUtil in = new InputUtil(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		CF_Task solver = new CF_Task();
		solver.solve(1, in, out);
		out.close();
	}
}

class CF_Task {
    // Documenting because the DP problem seems pretty cool

    // The mod used for the problem
    public static final int MOD = 1_000_000_007;

    // Array to store how many increments we need for each index
    int[] need;

    // The dp array
    public long[][] dp;

    // Solution method
    public void solve(int testNumber, InputUtil in, PrintWriter out) {

        // Inputs
        int n = in.nextInt();
        int h = in.nextInt();

        // Boolean to store if the problem has a solution
        boolean good = true;

        // Fill out the need array
        need = new int[n + 1];

        // Fill the array
        for (int i = 1; i <= n; i++) {

            // Get the number of increments for this element
            need[i] = h - in.nextInt();

            // The number of increments must be nonnegative
            good &= need[i] > -1;

            // Because we can only close and open at most one segment
            // The difference between adjacent element cannot be more than one
            good &= Math.abs(need[i] - need[i - 1]) < 2;
        }

        // Make sure to check that the last element is under 2
        good &= need[n] < 2;

        // If there's no solution
        if (!good) {
            out.println("0");
            return;
        }

        // Generate the DP array
        dp = new long[n + 1][2];

        // Start of the array:
        dp[0][0] = 1;

        // Fill in the DP array
        for (int i = 1; i <= n; i++) {

            /* Maintaining increments */

            // Do nothing
            dp[i][0] += get(i - 1, need[i]);

            // If we can open a sequence
            if (need[i] > 0) {
                
                // Open one sequence
                dp[i][0] += get(i - 1, need[i] - 1);
            }

            /* Reducing increments by one */

            // Open a sequence and then close one
            if (need[i] > 0) {
                dp[i][1] += get(i - 1, need[i] - 1) * need[i];
            }

            // Closing one sequence
            dp[i][1] += get(i - 1, need[i]) * need[i];

            // Mod
            dp[i][0] %= MOD;
            dp[i][1] %= MOD;
        }

        // Debug
//        for (int i = 1; i <= n; i++) {
//            System.out.println(Arrays.toString(dp[i]));
//        }

        // Print out the answer
        out.println(dp[n][need[n]]);
    }

    // Pulls the answer from the dp array if it exists
    public long get(int idx, int s) {
        int x = need[idx] - s;
        return x == 0 || x == 1 ? dp[idx][x] : 0L;
    }
}

class InputUtil {

    JoltyScanner in;

    public InputUtil(InputStream istream) {
        in = new JoltyScanner(istream);
    }

    public String next() {
        return in.nextOrNull();
    }

    public int nextInt() {
        String s = next();
        if (s == null) {
            throw new NoSuchElementException("Attempted to read integer that is not there.");
        }
        return Integer.parseInt(s);
    }

}

class JoltyScanner {
    public static final int BUFFER_SIZE = 1 << 16;
	public static final char NULL_CHAR = (char) -1;

	StringBuilder str = new StringBuilder();
	byte[] buffer = new byte[BUFFER_SIZE];
	boolean EOF_FLAG = false;
	int bufferIdx = 0, size = 0;
	char c = NULL_CHAR;
	BufferedInputStream in;

	public JoltyScanner(InputStream in) {
		this.in = new BufferedInputStream(in, BUFFER_SIZE);
	}

    public String next() {
		checkEOF();
		if (c == NULL_CHAR) {
			c = nextChar();
		}
		while (Character.isWhitespace(c)) {
			c = nextChar();
			checkEOF();
		}
		str.setLength(0);
		for (; !EOF_FLAG && !Character.isWhitespace(c); c = nextChar()) {
			str.append(c);
		}
		return str.toString();
	}

	public String nextOrNull() {
		try {
			return next();
		} catch (EndOfFileException e) {
			return null;
		}
	}

    public char nextChar() {
		if (EOF_FLAG) {
			return NULL_CHAR;
		}
		while (bufferIdx == size) {
			try {
				size = in.read(buffer);
				if (size == -1) {
					throw new Exception();
				}
			} catch (Exception e) {
				EOF_FLAG = true;
				return NULL_CHAR;
			}
			if (size == -1) {
				size = BUFFER_SIZE;
			}
			bufferIdx = 0;
		}
		return (char) buffer[bufferIdx++];
	}

    public void checkEOF() {
		if (EOF_FLAG) {
			throw new EndOfFileException();
		}
	}

	public class EndOfFileException extends RuntimeException {
	}
}

