#include <iostream>
using namespace std;

const long long mod = 1000000007;
const int MAX_N = 250;
const int MAX_K = 50;

int N, K, M, A[1 << 18];
int cnt[1 << 18];
long long dp[25009][409], S[25009];
long long dp2[25009][409], S2[25009];
bool used[1 << 18];

bool check() {
	if (K > M) return false;

	int rem = 0;
	for (int i = 1; i <= K; i++) cnt[i] = 0;
	for (int i = 1; i <= K; i++) { cnt[A[i]]++; if (cnt[A[i]] == 2) rem++; }
	if (rem == 0) return true;

	for (int i = K + 1; i <= M; i++) {
		cnt[A[i - K]]--; if (cnt[A[i - K]] == 1) rem--;
		cnt[A[i]]++; if (cnt[A[i]] == 2) rem++;
		if (rem == 0) return true;
	}
	return false;
}

long long modpow(long long a, long long b, long long m) {
	long long p = 1, q = a;
	for (int i = 0; i < 32; i++) {
		if ((b / (1LL << i)) % 2 == 1) { p *= q; p %= m; }
		q *= q; q %= m;
	}
	return p;
}

long long Div(long long a, long long b, long long m) {
	return (a * modpow(b, m - 2, m)) % m;
}

long long solve1() {
	int cl = -1, cr = -1;
	for (int i = 1; i <= K; i++) used[i] = false;
	for (int i = 1; i <= M; i++) {
		if (used[A[i]] == true) { cl = i - 1; break; }
		used[A[i]] = true;
	}
	for (int i = 1; i <= K; i++) used[i] = false;
	for (int i = M; i >= 1; i--) {
		if (used[A[i]] == true) { cr = M - i; break; }
		used[A[i]] = true;
	}

	dp[0][cl] = 1;
	for (int i = 1; i <= N; i++) {
		long long r = 0;
		for (int j = K - 1; j >= 1; j--) {
			r += dp[i - 1][j]; r %= mod;
			dp[i][j] = r + dp[i - 1][j - 1] * (K - j + 1);
			dp[i][j] %= mod;
		}
	}

	dp2[0][cr] = 1;
	for (int i = 1; i <= N; i++) {
		long long r = 0;
		for (int j = K - 1; j >= 1; j--) {
			r += dp2[i - 1][j]; r %= mod;
			dp2[i][j] = r + dp2[i - 1][j - 1] * (K - j + 1);
			dp2[i][j] %= mod;
		}
	}

	for (int i = 0; i <= N; i++) {
		for (int j = 1; j <= K - 1; j++) {
			S[i] += dp[i][j]; S[i] %= mod;
			S2[i] += dp2[i][j]; S2[i] %= mod;
		}
	}

	long long sum = 0;
	for (int i = 1; i <= N - M + 1; i++) {
		long long f = S[i - 1] * S2[N - M - i + 1] % mod;
		long long g = modpow(K, N - M, mod);
		sum += (g - f + mod) % mod;
		sum %= mod;
	}
	return sum;
}

long long solve2() {
	dp[0][0] = 1;
	for (int i = 1; i <= N; i++) {
		long long r = 0;
		for (int j = K - 1; j >= 1; j--) {
			r += dp[i - 1][j]; r %= mod;
			dp[i][j] = r + dp[i - 1][j - 1] * (K - j + 1);
			dp[i][j] %= mod;
		}
		long long r2 = 0;
		for (int j = K - 1; j >= 1; j--) {
			r2 += dp2[i - 1][j]; r2 %= mod;
			dp2[i][j] = r2 + dp2[i - 1][j - 1] * (K - j + 1);
			dp2[i][j] %= mod;
		}
		for (int j = M; j <= K - 1; j++) {
			dp2[i][j] += dp[i][j];
			dp2[i][j] %= mod;
		}
	}

	long long rem = 0;
	for (int i = 1; i <= K; i++) { rem += dp2[N][i]; rem %= mod; }

	long long fac = 1;
	for (int i = K; i >= K - M + 1; i--) { fac *= (1LL * i); fac %= mod; }
	fac = Div(1, fac, mod);

	long long val1 = rem * fac % mod;
	long long val2 = (N - M + 1);
	val2 *= modpow(K, N - M, mod);
	val2 %= mod;

	return (val2 - val1 + mod) % mod;
}

int main() {
	cin >> N >> K >> M;
	for (int i = 1; i <= M; i++) { cin >> A[i]; cnt[A[i]]++; }

	bool flag = false;
	for (int i = 1; i <= K; i++) { if (cnt[i] >= 2) flag = true; }

	int ans = -1;
	if (check() == true) {
		ans = 1LL * (N - M + 1) * modpow(K, N - M, mod) % mod;
	}
	else if (flag == true) {
		ans = solve1();
	}
	else if (flag == false) {
		ans = solve2();
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 161792