#include <bits/stdc++.h>
using namespace std;
const int MX = 200005, mod = 998244353;
int n, m;
long long s[MX], tot, d[MX], fac[MX], inv[MX];
long long pot(long long b, int p) {
  long long res = 1;
  while (p) {
    if (p & 1) (res *= b) %= mod;
    (b *= b) %= mod;
    p /= 2;
  }
  return res;
}
long long comb(int n, int k) {
  if (n < 0 || k < 0 || n < k) return 0;
  return fac[n] * inv[k] % mod * inv[n - k] % mod;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  fac[0] = inv[0] = 1;
  for (int i = 1; i < MX; i++) {
    fac[i] = i * fac[i - 1] % mod;
    inv[i] = pot(fac[i], mod - 2);
  }
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> d[i];
  sort(d, d + n);
  for (int i = 0; i < n; i++) {
    (tot += d[i]) %= mod;
    s[i] = d[i];
    if (i) (s[i] += s[i - 1]) %= mod;
  }
  while (m--) {
    long long a, b;
    cin >> a >> b;
    int j = lower_bound(d, d + n, b) - d;
    long long izq = j ? s[j - 1] : 0;
    long long der = tot - izq;
    long long cn = n - j;
    long long res = 0;
    if (cn < a) {
      cout << 0 << '\n';
      continue;
    }
    (res += der * (cn - a) % mod * pot(cn, mod - 2)) %= mod;
    (res += izq * (cn - a + 1) % mod * pot(cn + 1, mod - 2)) %= mod;
    cout << ((((res) % (mod)) + (mod)) % (mod)) << '\n';
  }
  return 0;
}
