#include #include using i64 = long long; template struct Mint { inline static constexpr T mod = MOD; T v; Mint() : v(0) {} Mint(signed v) : v(v) {} Mint(long long t) { v = t % MOD; if (v < 0) v += MOD; } Mint pow(long long k) { Mint res(1), tmp(v); while (k) { if (k & 1) res *= tmp; tmp *= tmp; k >>= 1; } return res; } static Mint add_identity() { return Mint(0); } static Mint mul_identity() { return Mint(1); } Mint inv() { return pow(MOD - 2); } Mint &operator+=(Mint a) { v += a.v; if (v >= MOD) v -= MOD; return *this; } Mint &operator-=(Mint a) { v += MOD - a.v; if (v >= MOD) v -= MOD; return *this; } Mint &operator*=(Mint a) { v = 1LL * v * a.v % MOD; return *this; } Mint &operator/=(Mint a) { return (*this) *= a.inv(); } Mint operator+(Mint a) const { return Mint(v) += a; } Mint operator-(Mint a) const { return Mint(v) -= a; } Mint operator*(Mint a) const { return Mint(v) *= a; } Mint operator/(Mint a) const { return Mint(v) /= a; } Mint operator+() const { return *this; } Mint operator-() const { return v ? Mint(MOD - v) : Mint(v); } bool operator==(const Mint a) const { return v == a.v; } bool operator!=(const Mint a) const { return v != a.v; } static Mint comb(long long n, int k) { Mint num(1), dom(1); for (int i = 0; i < k; i++) { num *= Mint(n - i); dom *= Mint(i + 1); } return num / dom; } }; template std::ostream &operator<<(std::ostream &os, Mint m) { os << m.v; return os; } using Z1 = Mint; using Z2 = Mint; void solve() { int n, k; std::cin >> n >> k; std::vector a(n); std::vector use(n); for (auto &i : a) { std::cin >> i; } std::fill(use.begin(), use.begin() + k, true); Z1 ans = 0; do { Z1 S1 = 0; Z2 S2 = 0; for (int i = 0; i < n; i++) { if (!use[i]) continue; S1 += a[i]; S2 += a[i]; } i64 ans1 = S1.v, ans2 = S2.v; if (ans2 <= ans1) { ans += 1; } } while (std::prev_permutation(use.begin(), use.end())); std::cout << ans << '\n'; } int main() { std::cin.tie(nullptr)->sync_with_stdio(false); solve(); return 0; }