#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
const long long mod = 998244353;
long long n, m, sum[N], d[N], a, b;
long long qkpow(long long a, long long b) {
  long long sum = 1;
  while (b) {
    if (b & 1) sum = sum * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return sum % mod;
}
int main() {
  cin >> n >> m;
  for (long long i = 1; i <= n; i++) cin >> d[i];
  sort(d + 1, d + 1 + n);
  for (long long i = 1; i <= n; i++) sum[i] = (sum[i - 1] + d[i]) % mod;
  while (m--) {
    cin >> a >> b;
    long long big = n - (lower_bound(d + 1, d + 1 + n, b) - (d + 1));
    if (a > big) {
      cout << 0 << '\n';
      continue;
    }
    long long ans1 =
        (sum[n] - sum[n - big]) * (1 - (a * qkpow(big, mod - 2)) % mod) % mod;
    long long ans2 =
        sum[n - big] * (1 - (a * qkpow(big + 1, mod - 2)) % mod) % mod;
    long long ans = ((ans1 + ans2) % mod + mod) % mod;
    cout << ans << '\n';
  }
  return 0;
}
