// IOI 2021
#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
 
////////////////////////////////////////////////////////////////////

const int N = 25e3 + 5, K = 4e2 + 5;

int n, m, k, A[N], DP[N][K], PS[N][K], C[N][K], PC[N][K], CNT[K], F[K];

int Power(int a, int b) {
	int res = 1;
	for (; b; b >>= 1, a = 1LL * a * a % MOD) if (b & 1) res = 1LL * res * a % MOD;
	return res;
}

int main() {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	mt19937 Rnd(time(0));
	
	F[0] = 1;
	for (int i = 1; i < K; i++) F[i] = 1LL * i * F[i - 1] % MOD;
	
	cin >> n >> k >> m;
	int ans = 1LL * (n - m + 1) * Power(k, n - m) % MOD;
	int inv = Power(F[k], MOD - 2);
	for (int i = 0; i < m; i++) cin >> A[i];

	for (int i = 0; i < m; i++) {
		memset(CNT, 0, sizeof CNT);
		int j = i;
		while (j < m && CNT[A[j]] == 0) CNT[A[j++]]++;
		if (j - i == k) die(ans);
	}
	memset(CNT, 0, sizeof CNT);
	int l = 0;
	while (l < m && CNT[A[l]] == 0) CNT[A[l++]]++;
	memset(CNT, 0, sizeof CNT);
	int r = 0;
	while (r < m && CNT[A[m - 1 - r]] == 0) CNT[A[m - 1 - r++]]++;
	bool dup = !(l == m && r == m);	

	PS[0][0] = DP[0][0] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j < k && j <= i; j++) {
			DP[i][j] = (1LL * DP[i - 1][j - 1] * (k - j + 1) % MOD + PS[i - 1][j]) % MOD;
		}
		for (int j = k - 1; j >= 1; j--) PS[i][j] = (PS[i][j + 1] + DP[i][j]) % MOD;
	}
	if (dup) {
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j < k && j <= i; j++) C[i][j] = (1LL * C[i - 1][j - 1] * (k - j + 1) % MOD + PC[i - 1][j]) % MOD;
			if (i >= m) C[i][r] = (C[i][r] + 1LL * PS[i - m + l][l] * (1LL * F[k - l] * inv % MOD) % MOD) % MOD;
			for (int j = k - 1; j >= 1; j--) PC[i][j] = (PC[i][j + 1] + C[i][j]) % MOD;
		}
	} else {
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j < k && j <= i; j++) {
				C[i][j] = (1LL * C[i - 1][j - 1] * (k - j + 1) % MOD + PC[i - 1][j]) % MOD;
				if (j >= m) C[i][j] = (C[i][j] + 1LL * DP[i][j] * (1LL * F[k - m] * inv % MOD) % MOD) % MOD;
			}
			for (int j = k - 1; j >= 1; j--) PC[i][j] = (PC[i][j + 1] + C[i][j]) % MOD;
		}
	}
	cout << (ans - PC[n][1] + MOD) % MOD << endl;

	return 0;
}
