#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  

#pragma warning(disable:4996)  
#pragma comment(linker, "/STACK:336777216")  
using namespace std;

#define mp make_pair  
#define Fi first  
#define Se second  
#define pb(x) push_back(x)  
#define szz(x) ((int)(x).size())  
#define rep(i, n) for(int i=0;i<n;i++)  
#define all(x) (x).begin(), (x).end()  
#define ldb ldouble  

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 19;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

ll mypow(ll a, ll b) {
	ll rv = 1;
	while (b) {
		if (b % 2) rv = rv*a%MOD;
		a = a*a%MOD;
		b /= 2;
	}
	return rv;
}
ll mul_inv(ll a, ll b = MOD) {
	ll t1 = a, t2 = b, t3;
	ll v1 = 1, v2 = 0, v3;
	while (t2 != 1) {
		ll x = t1 / t2;
		t3 = t1 - x*t2;
		v3 = v1 - x*v2;
		t1 = t2, t2 = t3;
		v1 = v2, v2 = v3;
	}
	return (v2 + b) % b;
}

int in[25050];
ll dp[25050][405];
ll sum[25050][405];

bool chk[25050];

ll F[25050];
ll Finv[25050];
ll P(int a, int b) {
	if (a < b) return 0;
	return F[a] * Finv[a - b] % MOD;
}
int main() {
	int N, K, M, i, j, k;
	F[0] = 1;
	for (i = 1; i <= 25020; i++) F[i] = F[i - 1] * i % MOD;
	for (i = 0; i <= 25020; i++) Finv[i] = mul_inv(F[i]);
	scanf("%d %d %d", &N, &K, &M);
	for (i = 1; i <= M; i++) scanf("%d", &in[i]);

	int c1 = M, c2 = M;
	ll ans = mypow(K, N - M) * (N - M + 1) % MOD;

	for (i = 1; i <= M - K + 1; i++) {
		for (j = 1; j <= K; j++) chk[j] = false;
		for (j = i; j < i + K; j++) {
			if (chk[in[j]]) break;
			chk[in[j]] = true;
		}
		if(j >= i+K) return !printf("%lld\n", ans);
	}
	for (i = 1; i <= K; i++) chk[i] = false;
	for (i = 1; i <= M; i++) {
		if (chk[in[i]]) {
			c1 = i - 1;
			break;
		}
		chk[in[i]] = true;
	}
	for (i = 1; i <= K; i++) chk[i] = false;
	for (i = M; i >= 1; i--) {
		if (chk[in[i]]) {
			c2 = M - i;
			break;
		}
		chk[in[i]] = true;
	}
	for (i = 1; i < K; i++) dp[0][i] = 1;
	for (i = 1; i <= N; i++) {
		for (j = 1; j < K; j++) sum[i - 1][j] = (sum[i - 1][j - 1] + dp[i - 1][j]) % MOD;
		for (j = 1; j < K; j++) {
			dp[i][j] = dp[i - 1][j + 1] * (K - j) + sum[i - 1][j];
			dp[i][j] %= MOD;
		}
	}

	if (c1 != M) {
		for (i = 0; i <= N - M; i++) {
			ans -= dp[i][c1] * dp[N - M - i][c2] % MOD;
			ans = (ans + MOD) % MOD;
		}
	}
	else {
		for (i = 0; i <= N - M; i++) {
			for (j = 0; j < i && c1 + j < K; j++) {
				ll s = sum[i - j - 1][c1 + j] * dp[N - M - i][c1 + j] % MOD;
				s = s * P(K - c1, j) % MOD;
				ans = (ans - s + MOD) % MOD;
			}
			if (c1 + i < K) {
				ll s = P(K - c1, i) * dp[N - M - i][c1 + i] % MOD;
				ans = (ans - s + MOD) % MOD;
			}
		}
	}
	return !printf("%lld\n", ans);
}

Measured memory_bytes: 159104