#include <bits/stdc++.h>
using namespace std;
 
#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define si(c) ((int)(c).size())
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
#define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--)
#define all(c) (c).begin(), (c).end()
#define D(a) cerr << #a << "=" << a << endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair
 
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
mt19937_64 rng;

const int 
    M = 1e7 + 10,
    MOD = 1e9 + 7;

int inv[M], fact[M], ifact[M];

int comb(int m, int n) {
    if (m < 0 || n < 0 || n > m) return 0;
    return (ll) fact[m] * ifact[n] % MOD * ifact[m-n] % MOD;
}

int f(int a, int b, int c) {
    return (ll) fact[a+b+c] * inv[a+b] % MOD * a % MOD;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    rng.seed(time(0));

    inv[1] = 1;
    forsn(n,2,M) {
        inv[n] = ll(MOD - MOD/n) * inv[MOD%n] % MOD;
        assert((ll) inv[n] * n % MOD == 1);
    }
    fact[0] = ifact[0] = 1;
    forsn(n,1,M) {
        fact[n] = ll(n) * fact[n-1] % MOD;
        ifact[n] = ll(inv[n]) * ifact[n-1] % MOD;
        assert((ll) fact[n] * ifact[n] % MOD == 1);
    }

    ll ans = 0;
    int n,a; cin >> n >> a;
    for (int i = 1; i < a; i++) {
        for (int k = 0; k <= i; k++) {
            ll sign = k%2 ? MOD - 1 : 1;
            ans += sign * comb(i,k) % MOD * f(i-k, n-a, a-1-i) % MOD;
        }
    }
    for (int k = 0; k <= a; k++) {
        ll sign = k%2 ? MOD - 1 : 1;
        ans += sign * comb(a,k) % MOD * f(a-k, n-a, 0) % MOD;
    }

    cout << ans%MOD << endl;
    return 0;
}
