#include <bits/stdc++.h>
using namespace std;
const long long DIM = 2E5 + 7;
const long long MOD = 998244353;
long long fact[DIM], A[DIM], pref[DIM];
long long binpow(long long x, long long power) {
  long long mult = x % MOD;
  x = 1;
  while (power) {
    if (power & 1) x = (x * mult) % MOD;
    mult = (mult * mult) % MOD;
    power /= 2;
  }
  return x;
}
long long rev(long long x) { return binpow(x, MOD - 2); }
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  fact[0] = 1;
  for (long long i = 1; i < DIM; ++i) fact[i] = fact[i - 1] * i % MOD;
  long long n, m;
  cin >> n >> m;
  long long cnt = 0;
  for (long long i = 1; i <= n; ++i) {
    cin >> A[i];
  }
  sort(A + 1, A + 1 + n, greater<long long>());
  for (long long i = 1; i <= n; ++i) {
    pref[i] = (pref[i - 1] + A[i]) % MOD;
  }
  reverse(A + 1, A + 1 + n);
  while (m--) {
    long long a, b;
    cin >> a >> b;
    long long cnt = lower_bound(A + 1, A + 1 + n, b) - A;
    cnt = n - cnt + 1;
    if (cnt < a) {
      cout << 0 << '\n';
      continue;
    }
    long long sum = 0;
    if (cnt > 0)
      sum = ((fact[cnt - 1] * (cnt - a)) % MOD * rev(fact[cnt]) % MOD *
                 pref[cnt] % MOD +
             sum) %
            MOD;
    sum = (fact[cnt] * (cnt - a + 1) % MOD * rev(fact[cnt + 1]) % MOD *
               (pref[n] - pref[cnt]) % MOD +
           sum) %
          MOD;
    sum = (sum + MOD) % MOD;
    cout << sum << '\n';
  }
  return 0;
}
