#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
struct mint {
  int n;
  mint(int n_ = 0) : n(n_ % MOD) {
    if (n < 0) n += MOD;
  }
};
mint operator+(mint a, mint b) { return (a.n += b.n) >= MOD ? a.n - MOD : a.n; }
mint operator-(mint a, mint b) { return (a.n -= b.n) < 0 ? a.n + MOD : a.n; }
mint operator*(mint a, mint b) { return 1LL * a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }
ostream &operator<<(ostream &os, mint a) { return os << a.n; }
istream &operator>>(istream &is, mint &a) { return is >> a.n; }
mint inv(mint x) {
  long long a = x.n, b = MOD, u = 1, v = 0;
  while (b) {
    long long t = a / b;
    swap((a -= t * b), b);
    swap((u -= t * v), v);
  }
  return mint(u);
}
mint operator^(mint a, long long n) {
  mint r = 1;
  while (n) {
    if (n & 1) r *= a;
    a *= a;
    n >>= 1;
  }
  return r;
}
bool operator<(const mint &a, const mint &b) { return a.n < b.n; }
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (auto &vi : vec) os << vi << " ";
  return os;
}
template <class T>
struct Matrix {
  vector<vector<T>> val;
  Matrix(int n = 1, int m = 1, T x = 0) { val.assign(n, vector<T>(m, x)); }
  size_t size() const { return val.size(); }
  vector<T> &operator[](int i) { return val[i]; }
  const vector<T> &operator[](int i) const { return val[i]; }
  friend ostream &operator<<(ostream &os, const Matrix<T> M) {
    for (int i = 0; i < M.size(); ++i) os << M[i] << " \n"[i != M.size() - 1];
    return os;
  }
};
template <class T>
Matrix<T> operator^(Matrix<T> A, long long n) {
  Matrix<T> R(A.size(), A.size());
  for (int i = 0; i < A.size(); ++i) R[i][i] = 1;
  while (n > 0) {
    if (n & 1) R = R * A;
    A = A * A;
    n >>= 1;
  }
  return R;
}
template <class T>
Matrix<T> operator*(const Matrix<T> &A, const Matrix<T> &B) {
  Matrix<T> R(A.size(), B[0].size());
  for (int i = 0; i < A.size(); ++i)
    for (int j = 0; j < B[0].size(); ++j)
      for (int k = 0; k < B.size(); ++k) R[i][j] += A[i][k] * B[k][j];
  return R;
}
template <class T>
vector<T> operator*(const Matrix<T> &A, vector<T> &B) {
  vector<T> v(A.size());
  for (int i = 0; i < A.size(); ++i)
    for (int k = 0; k < B.size(); ++k) v[i] += A[i][k] * B[k];
  return v;
}
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int &ai : a) cin >> ai;
  int cnt0 = count(a.begin(), a.end(), 0);
  int ng1 = count(a.begin(), a.begin() + cnt0, 1);
  vector<mint> state(cnt0 + 1);
  state[cnt0 - ng1] = 1;
  Matrix<mint> trans(cnt0 + 1, cnt0 + 1);
  for (int ok0 = 0; ok0 <= cnt0; ok0++) {
    mint dec = ok0 * (n + ok0 - 2 * cnt0);
    mint inc = (cnt0 - ok0) * (cnt0 - ok0);
    if (ok0 > 0) trans[ok0 - 1][ok0] = dec;
    trans[ok0][ok0] = n * (n - 1) * inv(2) - dec - inc;
    if (ok0 < cnt0) trans[ok0 + 1][ok0] = inc;
  }
  auto res = (trans ^ k) * state;
  auto sum = accumulate(res.begin(), res.end(), mint(0));
  cout << res[cnt0] * inv(sum) << endl;
  return 0;
}
