#include <bits/stdc++.h>

using namespace std;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
    ifstream t("/proc/self/status");
    cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getchar());
	for(; !isdigit(ch); ch = getchar()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) - '0' + ch;
	return sum * fg;
}

typedef long long LL;
typedef long double LD;
typedef pair<int, int> pii;

const int MOD = (int) 1e9 + 7;
const int MAXN = (int) 2.5e4, MAXK = 400;

int n, k, m;
int A[MAXN + 5];

inline void input()
{
	n = read<int>(), k = read<int>(), m = read<int>();
	for(int i = 1; i <= m; ++i) A[i] = read<int>();
}

inline int chk_type()
{
	static int vis[MAXN + 5];

	int p = 0, fg = 0;
	for(int i = 1; i <= m; ++i)
	{
		if(vis[A[i]]) fg = 1, chkmax(p, vis[A[i]]);
		if(i - p == k) return 0;
		vis[A[i]] = i;
	}
	return fg ? 2 : 1;
}

inline int fpm(int x, int y)
{
	int res = 1;
	for(; y; y >>= 1, x = (LL) x * x % MOD) if(y & 1) res = (LL) res * x % MOD;
	return res;
}

inline int CNT() { return (LL) (n - m + 1) * fpm(k, n - m) % MOD; }

inline int SPE()
{
	static int f[MAXN + 5][MAXK + 5], g[MAXN + 5][MAXK + 5];
	static int suff[MAXN + 5][MAXK + 5], sufg[MAXN + 5][MAXK + 5];

	f[0][0] = 1, suff[0][0] = 1;
	for(int i = 1; i <= n; ++i)
	{
		for(int j = 1; j < k; ++j)
		{
			f[i][j] = (LL) f[i - 1][j - 1] * (k - j + 1) % MOD;
			(f[i][j] += suff[i - 1][j]) %= MOD;

			g[i][j] = (LL) g[i - 1][j - 1] * (k - j + 1) % MOD;
			(g[i][j] += sufg[i - 1][j]) %= MOD;
			if(j >= m) (g[i][j] += f[i][j]) %= MOD;
		}

		for(int j = k - 1; j; --j)
		{
			suff[i][j] = (suff[i][j + 1] + f[i][j]) % MOD;
			sufg[i][j] = (sufg[i][j + 1] + g[i][j]) % MOD;
		}
	}

	int res = 0;
	for(int i = 1; i < k; ++i) (res += g[n][i]) %= MOD;
	for(int i = 0; i < m; ++i) res = (LL) res * fpm(k - i, MOD - 2) % MOD;
	return res;
}

inline void get_lr_pos(int &l, int &r)
{
	static bool vis[MAXN + 5];

	memset(vis, 0, sizeof vis);
	for(int i = 1; i <= m; ++i)
	{
		if(vis[A[i]]) { l = i - 1; break; }
		vis[A[i]] = 1;
	}

	memset(vis, 0, sizeof vis);
	for(int i = m; i; --i)
	{
		if(vis[A[i]]) { r = i + 1; break; }
		vis[A[i]] = 1;
	}
	r = m - r + 1;
}

inline int DP()
{
	static int l, r;
	get_lr_pos(l, r);

	static int f[MAXN + 5][MAXK + 5], suff[MAXN + 5][MAXK + 5];

	f[0][l] = 1;
	for(int i = 1; i <= l; ++i) suff[0][i] = 1;
	for(int i = 1; i <= n; ++i)
	{
		for(int j = 1; j < k; ++j)
		{
			f[i][j] = (LL) f[i - 1][j - 1] * (k - j + 1) % MOD;
			(f[i][j] += suff[i - 1][j]) %= MOD;
		}

		for(int j = k - 1; j; --j) suff[i][j] = (suff[i][j + 1] + f[i][j]) % MOD;
	}

	static int g[MAXN + 5][MAXK + 5], sufg[MAXN + 5][MAXK + 5];

	g[0][r] = 1;
	for(int i = 1; i <= r; ++i) sufg[0][i] = 1;
	for(int i = 1; i <= n; ++i)
	{
		for(int j = 1; j < k; ++j)
		{
			g[i][j] = (LL) g[i - 1][j - 1] * (k - j + 1) % MOD;
			(g[i][j] += sufg[i - 1][j]) %= MOD;
		}

		for(int j = k - 1; j; --j) sufg[i][j] = (sufg[i][j + 1] + g[i][j]) % MOD;
	}

	int ans = 0;
	for(int i = 1; i <= n - m + 1; ++i)
	{
		int llen = i - 1, rlen = n - (i + m - 1);
		int lall = fpm(k, llen), ldp = (lall - suff[llen][1]) % MOD,
			rall = fpm(k, rlen), rdp = (rall - sufg[rlen][1]) % MOD;

		(ans += (LL) ldp * rall % MOD) %= MOD;
		(ans += (LL) lall * rdp % MOD) %= MOD;
		(ans -= (LL) ldp * rdp % MOD) %= MOD;
	}
	return ans;
}

int main()
{
//	freopen("F.in", "r", stdin);
//	freopen("F.out", "w", stdout);

	input();
	int type = chk_type();
	if(type == 0) printf("%d\n", CNT());
	if(type == 1) printf("%d\n", ((CNT() - SPE()) % MOD + MOD) % MOD);
	if(type == 2) printf("%d\n", (DP() + MOD) % MOD);

	return 0;
}



Measured memory_bytes: 160000