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

template <int MOD_> struct modnum {
	static constexpr int MOD = MOD_;
	static_assert(MOD_ > 0, "MOD must be positive");
 
private:
	using ll = long long;
 
	int v;
 
	static int minv(int a, int m) {
		a %= m;
		assert(a);
		return a == 1 ? 1 : int(m - ll(minv(m, a)) * ll(m) / a);
	}
 
public:
 
	modnum() : v(0) {}
	modnum(ll v_) : v(int(v_ % MOD)) { if (v < 0) v += MOD; }
	explicit operator int() const { return v; }
	friend std::ostream& operator << (std::ostream& out, const modnum& n) { return out << int(n); }
	friend std::istream& operator >> (std::istream& in, modnum& n) { ll v_; in >> v_; n = modnum(v_); return in; }
 
	friend bool operator == (const modnum& a, const modnum& b) { return a.v == b.v; }
	friend bool operator != (const modnum& a, const modnum& b) { return a.v != b.v; }
 
	modnum inv() const {
		modnum res;
		res.v = minv(v, MOD);
		return res;
	}
	modnum neg() const {
		modnum res;
		res.v = v ? MOD-v : 0;
		return res;
	}
 
	modnum operator- () const {
		return neg();
	}
	modnum operator+ () const {
		return modnum(*this);
	}
 
	modnum& operator ++ () {
		v ++;
		if (v == MOD) v = 0;
		return *this;
	}
	modnum& operator -- () {
		if (v == 0) v = MOD;
		v --;
		return *this;
	}
	modnum& operator += (const modnum& o) {
		v += o.v;
		if (v >= MOD) v -= MOD;
		return *this;
	}
	modnum& operator -= (const modnum& o) {
		v -= o.v;
		if (v < 0) v += MOD;
		return *this;
	}
	modnum& operator *= (const modnum& o) {
		v = int(ll(v) * ll(o.v) % MOD);
		return *this;
	}
	modnum& operator /= (const modnum& o) {
		return *this *= o.inv();
	}
 
	friend modnum operator ++ (modnum& a, int) { modnum r = a; ++a; return r; }
	friend modnum operator -- (modnum& a, int) { modnum r = a; --a; return r; }
	friend modnum operator + (const modnum& a, const modnum& b) { return modnum(a) += b; }
	friend modnum operator - (const modnum& a, const modnum& b) { return modnum(a) -= b; }
	friend modnum operator * (const modnum& a, const modnum& b) { return modnum(a) *= b; }
	friend modnum operator / (const modnum& a, const modnum& b) { return modnum(a) /= b; }
};
using num = modnum<int(1e9) + 7>;

using ll = long long;

num powmod(num a, ll b) { num r = 1; while (b) { if (b & 1) r *= a; a *= a; b /= 2; } return r; }

const int MAXN = 25010;
const int MAXK = 410;
int N, K, M;

bool isColorful(vector<int> a) {
	set<int> s;
	for (int i = 0, j = 0; i < int(a.size()); i++) {
		while (j < int(a.size()) && !s.count(a[j])) {
			s.insert(a[j]);
			j++;
		}
		assert(int(s.size()) == j-i);
		if (j-i == K) return true;
		s.erase(a[i]);
	}
	return false;
}

int maxDistinct(vector<int> a) {
	int res = 0;
	set<int> s;
	while (res < int(a.size()) && !s.count(a[res])) {
		s.insert(a[res]);
		res++;
	}
	return res;
}

num dp[MAXN][MAXK];
num dptot[MAXN][MAXK];

num fact(int n) {
	num res = 1;
	for (int i = 1; i <= n; i++) {
		res *= i;
	}
	return res;
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N >> K >> M;
	vector<int> A(M);
	for (int i = 0; i < M; i++) {
		cin >> A[i];
	}

	num ans = (N-M+1) * powmod(K, N-M);
	if (isColorful(A)) { // any sequence is ok
		cout << ans << '\n';
		exit(0);
	}

	int pref = maxDistinct(A);
	int suff = maxDistinct(vector<int>(A.rbegin(), A.rend()));
	if (pref == int(A.size())) {
		assert(pref == suff);
		dp[0][0] = 1;
		for (int i = 0; i < N; i++) {
			num s = 0;
			num stot = 0;
			for (int j = K-1; j >= 1; j--) {
				s += dp[i][j];
				stot += dptot[i][j];
				dp[i+1][j] = s + dp[i][j-1] * (K-(j-1));
				dptot[i+1][j] = stot + dptot[i][j-1] * (K-(j-1));
			}
			for (int j = M; j < K; j++) {
				dptot[i+1][j] += dp[i+1][j];
			}
		}

		num tot = 0;
		for (int j = 1; j < K; j++) {
			tot += dptot[N][j];
		}
		tot /= fact(K) / fact(K-M);
		ans -= tot;
	} else {
		for (int j = 1; j < K; j++) {
			dp[0][j] = 1;
		}
		for (int i = 0; i < N; i++) {
			num s = 0;
			for (int j = 1; j < K; j++) {
				s += dp[i][j];
				dp[i+1][j] = dp[i][j+1] * (K-j) + s;
			}
		}

		for (int i = 0; i <= N-M; i++) {
			ans -= dp[i][pref] * dp[N-M-i][suff];
		}
	}
	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 80640