#include <bits/stdc++.h>
using namespace std;
constexpr long long INF = 2e18;
constexpr long long MOD = 998244353;
constexpr long long MAXN = 2e5 + 3;
long long mod(long long n) {
  n %= MOD;
  if (n < 0) n += MOD;
  return n;
}
class Combinatorics {
 private:
  const long long max_val;
  vector<long long> _inv, _fat;

 private:
  long long mod(long long x) {
    x %= MOD;
    if (x < 0) x += MOD;
    return x;
  }
  static long long bin_pow(const long long n, long long p) {
    assert(p >= 0);
    long long ans = 1;
    long long cur_pow = n;
    while (p) {
      if (p & 1ll) ans = (ans * cur_pow) % MOD;
      cur_pow = (cur_pow * cur_pow) % MOD;
      p >>= 1ll;
    }
    return ans;
  }
  vector<long long> build_inverse(const long long max_val) {
    vector<long long> inv(max_val + 1);
    inv[1] = 1;
    for (long long i = 2; i <= max_val; ++i)
      inv[i] = mod(-MOD / i * inv[MOD % i]);
    return inv;
  }
  vector<long long> build_fat(const long long max_val) {
    vector<long long> fat(max_val + 1);
    fat[0] = 1;
    for (long long i = 1; i <= max_val; ++i) fat[i] = mod(i * fat[i - 1]);
    return fat;
  }

 public:
  Combinatorics(const long long max_val) : max_val(max_val) {
    assert(0 <= max_val), assert(max_val <= MOD);
    this->_inv = this->build_inverse(max_val);
    this->_fat = this->build_fat(max_val);
  }
  static long long inv_log(const long long n) { return bin_pow(n, MOD - 2); }
  long long inv(const long long n) {
    assert(0 <= n);
    if (n <= max_val)
      return this->_inv[n];
    else
      return inv_log(n);
  }
  long long fat(const long long n) {
    assert(0 <= n), assert(n <= max_val);
    return this->_fat[n];
  }
  long long choose(const long long n, const long long k) {
    assert(0 <= k), assert(k <= n), assert(n <= this->max_val);
    return mod(fat(n) * mod(inv(fat(k)) * inv(fat(n - k))));
  }
};
Combinatorics comb(1);
void solve() {
  long long n;
  cin >> n;
  long long q;
  cin >> q;
  vector<long long> d(n);
  for (long long &x : d) cin >> x;
  sort(d.begin(), d.end());
  vector<long long> pref(n + 1, 0);
  for (long long i = 0; i < n; ++i) pref[i + 1] = mod(pref[i] + d[i]);
  while (q--) {
    long long a, b;
    cin >> a >> b;
    long long idx = lower_bound(d.begin(), d.end(), b) - d.begin();
    long long big = n - idx;
    long long s1 = mod(pref[n] - pref[idx]);
    long long s2 = pref[idx];
    if (a > big || a == n) {
      cout << 0 << '\n';
    } else {
      long long ans = mod(mod(s1) * mod(big - a)) * comb.inv(big);
      ans = mod(ans);
      ans += mod(s2 * mod(big + 1 - a)) * comb.inv(big + 1);
      ans = mod(ans);
      cout << ans << '\n';
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr), cout.tie(nullptr);
  long long t = 1;
  while (t--) solve();
}
