#include <bits/stdc++.h>
const long long MOD = 998244353;
using pii = std::pair<long long, long long>;
using namespace std;
const long long maxn = 2e5 + 5;
long long n, m, d[maxn], a, b, ans[maxn];
long long mod_expo(long long x, long long p) {
  long long res = 1;
  x = ((x % MOD) + MOD) % MOD;
  while (p > 0) {
    if (p & 1) res = (res * x) % MOD;
    x = (x * x) % MOD;
    p /= 2;
  }
  return res;
}
long long mod_inv(long long x) { return mod_expo(x, MOD - 2); }
vector<long long> fact, inv_fact;
void precalculate_factorials(long long MAX_FACT) {
  fact.resize(MAX_FACT + 1);
  inv_fact.resize(MAX_FACT + 1);
  fact[0] = 1;
  for (long long i = 1; i <= MAX_FACT; i++) fact[i] = (fact[i - 1] * i) % MOD;
  inv_fact[MAX_FACT] = mod_inv(fact[MAX_FACT]);
  for (long long i = MAX_FACT - 1; i >= 0; i--)
    inv_fact[i] = (inv_fact[i + 1] * (i + 1)) % MOD;
}
long long nPr_mod(long long n, long long r) {
  return (n < r) ? 0 : (fact[n] * inv_fact[n - r]) % MOD;
}
long long nCr_mod(long long n, long long r) {
  return (n < r) ? 0 : (nPr_mod(n, r) * inv_fact[r]) % MOD;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  precalculate_factorials(maxn);
  cin >> n >> m;
  long long totsum = 0;
  for (long long i = 0; i < n; i++) {
    cin >> d[i];
    totsum += d[i];
  }
  sort(d, d + n);
  vector<pair<pii, long long>> order;
  for (long long i = 0; i < m; i++) {
    cin >> a >> b;
    order.push_back({{b, a}, i});
  }
  sort(order.begin(), order.end());
  long long ltcnt = 0, ltsum = 0;
  for (auto x : order) {
    a = x.first.second;
    b = x.first.first;
    long long idx = x.second;
    while (ltcnt < n && d[ltcnt] < b) {
      ltsum += d[ltcnt];
      ltcnt++;
    }
    long long geqcnt = n - ltcnt, geqsum = totsum - ltsum;
    long long geqans = ((geqsum % MOD) * max(geqcnt - a, 0ll)) % MOD;
    geqans *= fact[max(geqcnt - 1, 0ll)];
    geqans %= MOD;
    geqans *= fact[n];
    geqans %= MOD;
    geqans *= inv_fact[geqcnt];
    geqans %= MOD;
    long long ltans = ((ltsum % MOD) * max(geqcnt - a + 1, 0ll)) % MOD;
    ltans *= fact[geqcnt];
    ltans %= MOD;
    ltans *= fact[n];
    ltans %= MOD;
    ltans *= inv_fact[geqcnt + 1];
    ltans %= MOD;
    ans[idx] = (geqans + ltans) % MOD;
  }
  for (long long i = 0; i < m; i++)
    cout << (ans[i] * mod_inv(fact[n])) % MOD << "\n";
  return 0;
}
