#include <bits/stdc++.h>
using namespace std;
using ll = long long;
struct Matrix {
  int n, m;
  vector<vector<ll>> mat;
  Matrix(int n, int m) : n(n), m(m), mat(n, vector<ll>(m)) {}
  vector<ll> &operator[](int i) { return mat[i]; }
  const vector<ll> &operator[](int i) const { return mat[i]; }
  static Matrix identity(int n) {
    Matrix res(n, n);
    for (int i = 0; i < n; i++) res[i][i] = 1;
    return res;
  }
  Matrix operator*(const Matrix &rhs) const {
    assert(m == rhs.n);
    Matrix res(n, rhs.m);
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < rhs.m; j++) {
        for (int k = 0; k < m; k++) {
          res[i][j] += mat[i][k] * rhs[k][j] % 1000000007;
          res[i][j] %= 1000000007;
        }
      }
    }
    return res;
  }
  Matrix fexp(ll x) const {
    assert(n == m && x >= 0);
    Matrix res = identity(n), cur = *this;
    while (x) {
      if (x % 2) res = res * cur;
      cur = cur * cur;
      x /= 2;
    }
    return res;
  }
};
ll fexp(ll a, ll b) {
  ll res = 1;
  while (b) {
    if (b % 2) res = res * a % 1000000007;
    a = a * a % 1000000007;
    b /= 2;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, k, z = 0, s = 0;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    z += !a[i];
  }
  for (int i = 0; i < z; i++) s += !a[i];
  Matrix dp(z + 1, z + 1);
  for (int i = 0; i <= z; i++) {
    if (i < z) dp[i][i + 1] = (ll)(z - i) * (z - i);
    if (i > 0) dp[i][i - 1] = (ll)i * (n - (2 * z - i));
    dp[i][i] = (ll)n * (n - 1) / 2 - (z - i) * (z - i) - i * (n - (2 * z - i));
  }
  dp = dp.fexp(k);
  ll tot = 0;
  for (int j = 0; j <= z; j++) tot = (tot + dp[s][j]) % 1000000007;
  cout << dp[s][z] * fexp(tot, 1000000007 - 2) % 1000000007 << endl;
}
