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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

template<int MOD> struct modnum {
    int v;
    modnum() : v(0) {}
    modnum(ll _v) : v(_v % MOD) { if (v < 0) v += MOD; }
    explicit operator int() const { return v; }
    friend istream& operator >> (istream& i, modnum& n) { ll v; i >> v; n = modnum(v); return i; }
    friend ostream& operator << (ostream& o, const modnum& n) { return o << n.v; }

    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& 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 - () { modnum res; if (v) res.v = MOD - v; return res; }
    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; }

    modnum pow(ll e) const {
        if (e == 0) return 1;
        if (e & 1) return *this * this->pow(e-1);
        return (*this * *this).pow(e/2);
    }

    modnum inv() const {
        int g = MOD, x = 0, y = 1;
        for (int r = v; r != 0; ) {
            int q = g / r;
            g %= r; swap(g, r);
            x -= q * y; swap(x, y);
        }

        assert(g == 1);
        assert(y == MOD || y == -MOD);
        return x < 0 ? x + MOD : x;
    }
    modnum& operator /= (const modnum& o) { return (*this) *= o.inv(); }
    friend modnum operator / (const modnum& a, const modnum& b) { return modnum(a) /= modnum(b); }

    static int totient() {
        int tot = MOD, tmp = MOD;
        for (int p = 2; p * p <= tmp; p++) if (tmp % p == 0) {
            tot = tot / p * (p - 1);
            while (tmp % p == 0) tmp /= p;
        }
        if (tmp > 1) tot = tot / tmp * (tmp - 1);
        return tot;
    }

    static int primitive_root() {
        if (MOD == 1) return 0;
        if (MOD == 2) return 1;

        int tot = totient(), tmp = tot;
        vi tot_pr;
        for (int p = 2; p * p <= tmp; p++) if (tot % p == 0) {
            tot_pr.push_back(p);
            while (tmp % p == 0) tmp /= p;
        }
        if (tmp > 1) tot_pr.push_back(tmp);

        for (int r = 2; r < MOD; r++) if (__gcd(r, MOD) == 1) {
            bool root = true;
            for (int p : tot_pr) root &= modnum(r).pow(tot / p) != 1;
            if (root) return r;
        }
        assert(false);
    }

    static modnum generator() { static modnum g = primitive_root(); return g; }
    static int discrete_log(modnum v) {
        static const int M = ceil(sqrt(MOD));
        static unordered_map<int, int> table;
        if (table.empty()) {
            modnum e = 1;
            for (int i = 0; i < M; i++) { table[e.v] = i; e *= generator(); }
        }
        static modnum f = generator().pow(totient() - M);

        for (int i = 0; i < M; i++) {
            if (table.count(v.v)) return table[v.v] + i * M;
            v *= f;
        }
        assert(false);
    }

    static modnum fact(int n) {
        static vector<modnum<MOD>> fact = { 1 };
        while (fact.size() <= n)
            fact.push_back(fact.back() * fact.size());
        return fact[n];
    }

    static modnum ncr(int n, int r) {
        if (r < 0 || n < r) return 0;
        return fact(n) / (fact(r) * fact(n - r));
    }
};
using mn = modnum<int(1e9 + 7)>;
using vmn = vector<mn>;
using vvmn = vector<vmn>;

mn solve_unique(int N, int K, int M) {
    vmn ways(K), runs(K);
    ways[0] = 1;

    for (int i = 1; i <= N; i++) {
        vmn geq(K + 1), runt(K + 1);
        for (int u = K - 1; u >= 0; u--) {
            geq[u] = geq[u+1] + ways[u];
            runt[u] = runt[u+1] + runs[u];
        }

        vmn nways(K), nruns(K);
        for (int u = 1; u < K; u++) {
            nways[u] = geq[u] + ways[u-1] * (K - u + 1);
            nruns[u] = runt[u] + runs[u-1] * (K - u + 1) + (u >= M ? nways[u] : 0);
        }

        ways = nways;
        runs = nruns;
    }

    mn tot = 0;
    for (mn v : runs) tot += v;
    return tot / (mn::fact(K) / mn::fact(K-M));
}

mn solve_duplicate(int N, int K, int M, vi& a) {
    vvmn ways(N + 1, vmn(K));
    ways[0][0] = 1;

    for (int i = 1; i <= N; i++) {
        vmn geq(K + 1);
        for (int u = K - 1; u >= 0; u--) {
            geq[u] = geq[u+1] + ways[i-1][u];
        }
        for (int u = 1; u < K; u++) {
            ways[i][u] = geq[u] + ways[i-1][u-1] * (K - u + 1);
        }
    }
    for (int i = 0; i <= N; i++)
        for (int u = K - 2; u >= 0; u--)
            ways[i][u] += ways[i][u+1];

    int pref = 0; {
        vb seen(K + 1);
        while (!seen[a[pref]]) {
            seen[a[pref]] = true;
            pref++;
        }
    }

    int suff = 0; {
        vb seen(K + 1);
        while (!seen[a[M-1-suff]]) {
            seen[a[M-1-suff]] = true;
            suff++;
        }
    }

    mn res = 0;
    for (int pos = 0; pos + M <= N; pos++) {
        res += ways[pos + pref][pref] * ways[N - (pos + M) + suff][suff];
    }
    return res / (mn::fact(K) / mn::fact(K-pref)) / (mn::fact(K) / mn::fact(K-suff));
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    int N, K, M;
    cin >> N >> K >> M;

    vi a(M);
    for (int i = 0; i < M; i++)
        cin >> a[i];

    // number of occurences of a over all sequences of length N
    mn tot = mn(N - M + 1) * mn(K).pow(N - M);

    // is a already colorful?
    for (int i = 0; i + K <= M; i++) {
        vb seen(K + 1);
        for (int j = 0; j < K; j++)
            seen[a[i+j]] = true;
        int uniq = 0;
        for (bool b : seen) uniq += b;
        if (uniq == K) {
            cout << tot << endl;
            return 0;
        }
    }

    // is a composed of unique values?
    vb seen(K + 1);
    for (int v : a) seen[v] = true;
    int uniq = 0;
    for (bool b : seen) uniq += b;

    if (uniq == M) {
        cout << tot - solve_unique(N, K, M) << endl;
    } else {
        cout << tot - solve_duplicate(N, K, M, a) << endl;
    }

    return 0;
}



Measured memory_bytes: 40448