#include <bits/stdc++.h>
using namespace std;
vector<vector<long long>> matrix_multiply(vector<vector<long long>> a,
                                          vector<vector<long long>> b) {
  long long x = a.size(), y = a[0].size(), z = b[0].size(), i, j, k;
  vector<vector<long long>> ans(x, vector<long long>(z, 0));
  for (i = 0; i < x; i++) {
    for (j = 0; j < z; j++)
      for (k = 0; k < y; k++)
        ans[i][j] = (ans[i][j] + a[i][k] * b[k][j]) % 1000000007;
  }
  return ans;
}
long long gcd(long long a, long long b) {
  while (b != 0) {
    long long t = b;
    b = a % b;
    a = t;
  }
  return a;
}
long long mul_inv(long long a, long long b) {
  long long b0 = b, t, q;
  long long x0 = 0, x1 = 1;
  if (b == 1) return 1;
  while (a > 1) {
    q = a / b;
    t = b, b = a % b, a = t;
    t = x0, x0 = x1 - q * x0, x1 = t;
  }
  if (x1 < 0) x1 += b0;
  return x1;
}
long long division(long long a, long long b, long long p) {
  long long ans, inv;
  inv = mul_inv(b, p);
  ans = ((a % p) * inv) % p;
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n, q, i, j, k, c, x, aa, bb, xx, g, ans;
  cin >> n >> q;
  vector<int> a(n);
  c = 0;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] == 0) c++;
  }
  x = 0;
  for (i = 0; i < c; i++) {
    if (a[i] == 0) x++;
  }
  xx = x;
  vector<vector<long long>> t(n + 1, vector<long long>(n + 1, 0));
  for (x = 0; x <= n; x++) {
    if (x < n) {
      t[x][x + 1] = (c - x) * (c - x);
      aa = t[x][x + 1];
    } else
      aa = 0;
    if (x > 0) {
      t[x][x - 1] = x * (n - c - c + x);
      bb = t[x][x - 1];
    } else
      bb = 0;
    t[x][x] = n * (n - 1) / 2 - aa - bb;
  }
  vector<vector<vector<long long>>> cc(33);
  vector<long long> total(33);
  cc[0] = t;
  total[0] = n * (n - 1) / 2;
  for (i = 1; i < 33; i++) {
    cc[i] = matrix_multiply(cc[i - 1], cc[i - 1]);
    total[i] = (total[i - 1] * total[i - 1]) % 1000000007;
  }
  vector<vector<long long>> z(1, vector<long long>(n + 1, 0));
  z[0][xx] = 1;
  bb = 1;
  for (i = 0; i < 33; i++) {
    if ((1LL << i) & q) {
      z = matrix_multiply(z, cc[i]);
      bb = (bb * total[i]) % 1000000007;
    }
  }
  aa = z[0][c];
  g = gcd(aa, bb);
  aa /= g;
  bb /= g;
  ans = division(aa, bb, 1000000007);
  cout << ans << "\n";
  return 0;
}
