#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const int mod = 998244353;
long long d[maxn];
long long prefix[maxn];
long long qpow(long long a, long long b) {
  long long ans = 1;
  for (; b; b >>= 1, a = a * a % mod)
    if (b & 1) ans = ans * a % mod;
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, q;
  cin >> n >> q;
  for (int i = 1; i <= n; i++) cin >> d[i];
  sort(d + 1, d + 1 + n);
  for (int i = 1; i <= n; i++) prefix[i] = (prefix[i - 1] + d[i]) % mod;
  while (q--) {
    int a, b;
    cin >> a >> b;
    if (d[n] < b) {
      cout << 0 << "\n";
      continue;
    }
    int l = 1, r = n;
    while (l < r) {
      int mid = (l + r) / 2;
      if (d[mid] < b)
        l = mid + 1;
      else
        r = mid;
    }
    int cnt_greater = n - l + 1, attacked = max(0, cnt_greater - a);
    long long ans = 0;
    ans = (prefix[n] - prefix[l - 1] + mod) % mod * attacked % mod *
          qpow(cnt_greater, mod - 2) % mod;
    ans = (ans + prefix[l - 1] * (max(0, cnt_greater - a + 1)) % mod *
                     qpow(cnt_greater + 1, mod - 2) % mod) %
          mod;
    cout << ans << "\n";
  }
  return 0;
}
