#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Matrix = vector<vector<ll>>;
const ll MOD = 1e9 + 7;
Matrix prod(const Matrix &a, const Matrix &b) {
  int m = a.size();
  Matrix ret(m, vector<ll>(m, 0));
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < m; j++) {
      for (int k = 0; k < m; k++) {
        ret[i][j] += a[i][k] * b[k][j];
        ret[i][j] %= MOD;
      }
    }
  }
  return ret;
}
Matrix matpow(Matrix &a, ll n) {
  int m = a.size();
  Matrix ret(m, vector<ll>(m, 0));
  for (int i = 0; i < m; i++) ret[i][i] = 1;
  while (n) {
    if (n & 1) {
      ret = prod(ret, a);
    }
    a = prod(a, a);
    n /= 2;
  }
  return ret;
}
template <typename T>
T mypow(T a, T b) {
  if (b == 0) return 1;
  T tmp = mypow(a, b / 2);
  if (b % 2)
    return (((tmp * tmp) % MOD) * a) % MOD;
  else
    return (tmp * tmp) % MOD;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n, k;
  cin >> n >> k;
  ll zero = 0, cnt = 0;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == 0) zero++;
  }
  for (int i = 0; i < n; i++) {
    if (a[i] && i < zero) cnt++;
  }
  ll one = n - zero, mi = min(zero, one);
  Matrix mat(mi + 1, vector<ll>(mi + 1, 0));
  ll al = (n * (n - 1) / 2) % MOD;
  al = mypow(al, MOD - 2);
  for (ll i = 0; i <= mi; i++) {
    ll sum = (one * (one - 1) / 2) % MOD + (zero * (zero - 1) / 2) % MOD;
    sum += (i * (n - 2 * i)) % MOD;
    sum %= MOD;
    sum *= al;
    sum %= MOD;
    mat[i][i] = sum;
    if (i) {
      sum = (zero - i + 1) * (one - i + 1) % MOD;
      sum *= al;
      sum %= MOD;
      mat[i][i - 1] = sum;
    }
    if (i + 1 <= mi) {
      sum = (i + 1) * (i + 1) % MOD;
      sum *= al;
      sum %= MOD;
      mat[i][i + 1] = sum;
    }
  }
  mat = matpow(mat, k);
  cout << mat[0][cnt] << endl;
}
