#include <iostream>
#include <cstdint>
#include <vector>
#include <algorithm>

const uint32_t MOD = 1e9 + 7;
const uint32_t MAX_K = 404;
const uint32_t MAX_N = 2.5e4 + 10;

uint32_t n, k, m;
uint32_t seq[MAX_N];

void input() { 
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	std::cin >> n >> k >> m;

	for (uint32_t i = 0;i < m;i++) {
		std::cin >> seq[i];
		seq[i]--;
	}
}

uint32_t fast_pow(uint32_t a, uint32_t b) {
	if (b == 0) {
		return 1;
	}
	uint64_t ans = fast_pow(a, b / 2);
	ans = ans * ans % MOD;
	if (b % 2) {
		ans = ans * a % MOD;
	}
	return ans;
}

uint64_t fact[MAX_K];
uint64_t iFact[MAX_K];

uint32_t prefLen, suffLen;
bool containsFull;

void precalc() {
	fact[0] = iFact[0] = 1;
	for (uint32_t i = 1;i < MAX_K;i++) {
		fact[i] = fact[i - 1] * i % MOD;
		iFact[i] = fast_pow(fact[i], MOD - 2);
	}
	std::vector<bool> found(k, false);
	prefLen = 0;
	for (uint32_t i = 0;i < m;i++) {
		if (!found[seq[i]]) {
			found[seq[i]] = true;
			prefLen++;
		} else {
			break;
		}
	}
	std::fill(found.begin(), found.end(), false);
	suffLen = 0;
	for (uint32_t i = m - 1;i < m;i--) {
		if (!found[seq[i]]) {
			found[seq[i]] = true;
			suffLen++;
		} else {
			break;
		}
	}

	std::vector<uint32_t> lastInd(k, m);
	uint32_t matchCnt = 0;
	for (uint32_t i = 0;i < m;i++) {
		if ((lastInd[seq[i]] == m) || (lastInd[seq[i]] < i - matchCnt)) {
			matchCnt++;
		} else {
			matchCnt = i - lastInd[seq[i]];
		}
		lastInd[seq[i]] = i;
		if (matchCnt == k) {
			containsFull = true;
			break;
		}
	}
	std::cerr << "prefLen " << prefLen << "\n";
	std::cerr << "suffLen " << suffLen << "\n";
	std::cerr << "contFull " << containsFull << "\n";
}

uint64_t comb(uint32_t n, uint32_t k) {
	return fact[n] * iFact[k] % MOD * iFact[n - k] % MOD;
}
uint64_t iComb(uint32_t n, uint32_t k) {
	return iFact[n] * fact[k] % MOD * fact[n - k] % MOD;
}

uint32_t dp[MAX_N][MAX_K];
uint32_t dpSum[MAX_N][MAX_K + 1];

//colorful sequences with length n, where the only colourful thing are the last
//k characters
uint32_t seqCnt[MAX_N];

void calc_dp_sum(uint32_t i) {
	dpSum[i][0] = 0;
	for (uint32_t j = 0;j < MAX_K;j++) {
		dpSum[i][j + 1] = (dpSum[i][j] + dp[i][j]) % MOD;
	}
}

uint64_t dp_sum(uint32_t i, uint32_t k1, uint32_t k2) {
	return (dpSum[i][k2 + 1] + MOD - dpSum[i][k1]) % MOD;
}

void calc_dp() {
	dp[0][0] = 1;
	calc_dp_sum(0);

	for (uint32_t i = 1;i <= n;i++) {
		for (uint32_t j = 1;j <= k;j++) {
			dp[i][j] += (uint64_t) (dp[i - 1][j - 1]) * (k - j + 1) % MOD;
			dp[i][j] += dp_sum(i - 1, j, k);
			dp[i][j] %= MOD;
		}
		seqCnt[i] = dp[i][k];
		dp[i][k] = 0;

		calc_dp_sum(i);
	}
}

uint32_t count_all() {
	uint64_t ans = fast_pow(k, n - m);
	ans = ans * (n - m + 1) % MOD;
	return ans;
}

uint32_t count_wrong_sep() {
	uint32_t ans = 0;
	for (uint32_t i = 0;i + m <= n;i++) {
		uint32_t fCnt = i + prefLen;
		uint32_t sCnt = n - i - m + suffLen;

		uint64_t curF = 0;
		for (uint32_t j = prefLen;j < k;j++) {
			curF += dp[fCnt][j];
		}

		curF %= MOD;
		curF = curF * fact[k - prefLen] % MOD;
		curF = curF * iFact[k] % MOD;

		uint64_t curS = 0;
		for (uint32_t j = suffLen;j < k ;j++) {
			curS += dp[sCnt][j];
		}
		curS %= MOD;
		curS = curS * fact[k - suffLen] % MOD;
		curS = curS * iFact[k] % MOD;

		ans += curS * curF % MOD;
		ans %= MOD;
	}
	return ans;
}

uint32_t solve_whole() {
	uint64_t wrongCnt = 0;
	for (uint32_t i = 0;i + m <= n;i++) {
		uint32_t fCnt = i + m;
		for (uint32_t j = m;j <= k;j++) {
			uint32_t sCnt = n + j - i - m;
			if (sCnt > n) {
				continue;
			}
			uint64_t cur = dp[fCnt][j];

			cur = cur * iFact[k] % MOD * fact[k - m] % MOD;
			cur = cur * iFact[k] % MOD * fact[k - j] % MOD;

			cur = cur * dp_sum(sCnt, j, k) % MOD;;

			wrongCnt += cur;
			wrongCnt %= MOD;
		}
	}

	uint64_t ans = (count_all() + MOD - wrongCnt) % MOD;
	return ans;
}


uint32_t solve_sep() {
	return (count_all() + MOD - count_wrong_sep()) % MOD;
}

int main() {
	input();
	precalc();
	calc_dp();

	uint32_t ans;
	if (containsFull) {
		ans = count_all();
	} else if (prefLen == m) {
		ans = solve_whole();
	} else {
		ans = solve_sep();
	}
	std::cout << ans << "\n";
}




Measured memory_bytes: 79488