#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define pll pair <ll, ll>
#define pci pair <char, int>
#define pld pair <ld, ld>
#define ppld pair <pld, pld>
#define ppll pair <pll, pll>
#define pldl pair <ld, ll>
#define vll vector <ll>
#define vvll vector <vll>
#define vpll vector <pll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mll map <ll, ll>
#define fastmap gp_hash_table
#define cd complex <double>
#define vcd vector <cd>
#define PI 3.14159265358979
#pragma 03
using namespace std;
using namespace __gnu_pbds;
ll mod = 1e9 + 7;
ll binpow(ll a, ll b){
	if (b == 0) return 1;
	ll x = binpow(a, b / 2);
	x *= x; x %= mod;
	if (b % 2) return (x * a) % mod;
	else return x;
}
ll occ[405], a[25005];
ll dp1[25005][405], dp2[25005][405];
// dp2 is suffix, dp1 is dp
int main(){
	ll n, k, m; cin >> n >> k >> m;
	ll l = 0, r = 0;
	for (ll i = 1; i <= m; i++) cin >> a[i];
	// case 1: a is colorful.
	if (m >= k){
		ll cnt = 0;
		for (ll i = 1; i <= k; i++){
			if (!occ[a[i]]++) cnt++;
		}
		if (cnt == k){
			cout << binpow(k, n - m) * (n - m + 1) % mod << endl;
			return 0;
		}
		for (ll i = k + 1; i <= m; i++){
			if (!occ[a[i]]++) cnt++;
			if (!--occ[a[i - k]]) cnt--;
			if (cnt == k){
				cout << binpow(k, n - m) * (n - m + 1) % mod << endl;
				return 0;
			}
		}
	}
	// 
	set <ll> s;
	while (l != m && !s.count(a[l + 1])) s.insert(a[++l]);
	s.clear();
	while (r != m && !s.count(a[m - r])) s.insert(a[m - r++]);
	s.clear();
	// case 2: a is not colorful, but it's elements are pairwise distinct.
	if (l == m){
		ll ans = 0;
		dp1[1][1] = k;
		for (ll i = 1; i < n; i++){
			for (ll j = k - 1; j > 0; j--) dp1[i + 1][j] = (dp1[i + 1][j + 1] + dp1[i][j]) % mod;
			for (ll j = 1; j < k - 1; j++) (dp1[i + 1][j + 1] += (dp1[i][j] * (k - j))) %= mod;
		}
		for (ll i = 1; i < k; i++) dp2[n][i] = 1;
		for (ll i = n - 1; i > 0; i--){
			for (ll j = 1; j < k; j++) dp2[i][j] = (dp2[i][j - 1] + dp2[i + 1][j]) % mod;
			for (ll j = 1; j < k - 1; j++) (dp2[i][j] += (dp2[i + 1][j + 1] * (k - j))) %= mod;
		}
		for (ll i = 1; i <= n; i++){
			for (ll j = m; j < k; j++) (ans += (dp1[i][j] * dp2[i][j])) %= mod;
		}
		for (ll i = k; i > k - m; i--) (ans *= binpow(i, mod - 2)) %= mod;
		cout << (mod - ans + binpow(k, n - m) * (n - m + 1)) % mod;
		return 0;
	}
	// case 3: a is not colorful, and there are duplicate elements in a.
	else{
		ll ans = 0;
		dp1[0][l] = 1;
		for (ll i = 0; i < n; i++){
			for (ll j = k - 1; j > 0; j--) dp1[i + 1][j] = (dp1[i + 1][j + 1] + dp1[i][j]) % mod;
			for (ll j = 1; j < k - 1; j++) (dp1[i + 1][j + 1] += (dp1[i][j] * (k - j))) %= mod;
		}
		dp2[0][r] = 1;
		for (ll i = 0; i < n; i++){
			for (ll j = k - 1; j > 0; j--) dp2[i + 1][j] = (dp2[i + 1][j + 1] + dp2[i][j]) % mod;
			for (ll j = 1; j < k - 1; j++) (dp2[i + 1][j + 1] += (dp2[i][j] * (k - j))) %= mod;
		}
		for (ll i = 0; i <= n - m; i++){
			ll tmp1 = 0, tmp2 = 0;
			for (ll j = 1; j < k; j++) (tmp1 += dp1[i][j]) %= mod;
			for (ll j = 1; j < k; j++) (tmp2 += dp2[n - m - i][j]) %= mod;
			(ans += (tmp1 * tmp2)) %= mod;
		}
		cout << (mod - ans + binpow(k, n - m) * (n - m + 1)) % mod;
		return 0;
	}
}

Measured memory_bytes: 158720