#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9 + 7;
struct matrix {
  vector<vector<ll>> mat;
  matrix() {}
  matrix(int n, ll v) : mat(n, vector<ll>(n)) {
    for (int i = 0; i < n; ++i) mat[i][i] = v;
  }
  void resize(int n) {
    mat.resize(n);
    for (auto &it : mat) it.resize(n);
  }
};
int n, k;
vector<int> a;
ll ones, zeros;
int min_in_place;
vector<int> decrease, increase, notchange;
int mat_size;
matrix base_mat;
ll mod_exp(ll b, ll e) {
  ll res = 1;
  while (e) {
    if (e & 1) res = (res * b) % MOD;
    b = (b * b) % MOD;
    e >>= 1;
  }
  return res;
}
matrix mat_mul(matrix a, matrix b) {
  matrix res(mat_size, 0);
  for (int i = 0; i < mat_size; ++i) {
    for (int j = 0; j < mat_size; ++j) {
      for (int k = 0; k < mat_size; ++k) {
        res.mat[i][j] = (res.mat[i][j] + a.mat[i][k] * b.mat[k][j]) % MOD;
      }
    }
  }
  return res;
}
matrix mat_exp(matrix b, ll e) {
  matrix res(mat_size, 1);
  while (e) {
    if (e & 1) res = mat_mul(res, b);
    b = mat_mul(b, b);
    e >>= 1;
  }
  return res;
}
void build() {
  increase.resize(ones + 1);
  decrease.resize(ones + 1);
  notchange.resize(ones + 1);
  min_in_place = max(0, 2 * (int)ones - n);
  mat_size = ones - min_in_place + 1;
  base_mat.resize(mat_size);
  for (int state = min_in_place; state <= ones; ++state) {
    ll inv_nn1 = (mod_exp(n, MOD - 2) * mod_exp(n - 1, MOD - 2)) % MOD;
    base_mat.mat[state - min_in_place][state - min_in_place] =
        ((ones * (ones - 1 + MOD) + zeros * (zeros - 1 + MOD) +
          2 * state * (ones - state) +
          2 * (ones - state) * (zeros - (ones - state) + MOD)) %
         MOD) *
        inv_nn1 % MOD;
    if (state > min_in_place) {
      base_mat.mat[state - min_in_place - 1][state - min_in_place] =
          (2 * state * (zeros - (ones - state) + MOD) % MOD) * inv_nn1 % MOD;
    }
    if (state < ones) {
      base_mat.mat[state - min_in_place + 1][state - min_in_place] =
          2 * (ones - state) * (ones - state) * inv_nn1 % MOD;
    }
  }
}
int main() {
  cin >> n >> k;
  a.resize(n);
  for (auto &it : a) {
    cin >> it;
    if (it)
      ++ones;
    else
      ++zeros;
  }
  build();
  matrix final_mat = mat_exp(base_mat, k);
  int initial_state = 0;
  for (int i = n - ones; i < n; ++i) initial_state += a[i];
  cout << final_mat.mat[ones - min_in_place][initial_state - min_in_place]
       << "\n";
  return 0;
}
