#include<bits/stdc++.h>
using namespace std;
const int N = 25010, K = 405, p = 1e9 + 7;
int n, k, m, a[N], ans, bk[K], f1[N][K], f2[N][K];
inline void A(int &x, int y) { x = (x + y >= p ? x + y - p : x + y); }
inline int Qmi(int x, int y = p - 2) {
	int ans = 1;
	for (; y; y >>= 1, x = 1ll * x * x % p) if (y & 1) ans = 1ll * ans * x % p;
	return ans;
}
inline void Dp(int f[N][K], int st) {
	f[0][st] = 1;
	for (int i = 0; i < n; ++i) {
		for (int j = 1; j < k; ++j) A(f[i][0], f[i][j]);
		for (int j = 1; j < k; ++j) {
			A(f[i + 1][1], f[i][j]);
			A(f[i + 1][j + 1], 1ll * (k - j - 1) * f[i][j] % p);
			A(f[i + 1][j + 2], p - 1ll * (k - j) * f[i][j] % p);
		}
		for (int j = 2; j < k; ++j) A(f[i + 1][j], f[i + 1][j - 1]);
	}
}
inline void _Dp() {
	f1[0][0] = 1;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < k; ++j) {
			A(f1[i + 1][1], f1[i][j]);
			A(f1[i + 1][j + 1], 1ll * (k - j - 1) * f1[i][j] % p);
			A(f1[i + 1][j + 2], p - 1ll * (k - j) * f1[i][j] % p);
			A(f2[i + 1][1], f2[i][j]);
			A(f2[i + 1][j + 1], 1ll * (k - j - 1) * f2[i][j] % p);
			A(f2[i + 1][j + 2], p - 1ll * (k - j) * f2[i][j] % p);
		}
		for (int j = 2; j < k; ++j) {
			A(f1[i + 1][j], f1[i + 1][j - 1]);
			A(f2[i + 1][j], f2[i + 1][j - 1]);
		}
		for (int j = m; j < k; ++j) A(f2[i + 1][j], f1[i + 1][j]);
	}
}
int main() {
	scanf("%d%d%d", &n, &k, &m);
	for (int i = 1; i <= m; ++i) scanf("%d", a + i);
	int ans = 1ll * (n - m + 1) * Qmi(k, n - m) % p;
	int F = 0, B = 0, flag = 0;
	for (int l = 1, r = 1; r <= m; ++r) {
		++bk[a[r]];
		while (bk[a[r]] > 1) --bk[a[l++]];
		if (l == 1) F = r;
		if (r == m) B = r - l + 1;
		if (r - l + 1 == k) flag = 1;
	}
	if (flag) {
		printf("%d\n", ans);
	} else if (F == m) {
		_Dp();
		int sum = 0, fac = 1;
		for (int i = 1; i < k; ++i) A(sum, f2[n][i]);
		for (int i = k - m + 1; i <= k; ++i) fac = 1ll * fac * i % p;
		sum = 1ll * sum * Qmi(fac) % p;
		A(ans, p - sum);
		printf("%d\n", ans);
	} else {
		Dp(f1, F);
		Dp(f2, B);
		for (int i = 0; i + m <= n; ++i) ans = (ans - 1ll * f1[i][0] * f2[n - i - m][0]) % p;
		if (ans < 0) ans += p;
		printf("%d\n", ans);
	}
	return 0;
}