#include <bits/stdc++.h>
using namespace std;
const unsigned long long mod = 998244353;
unsigned long long fast_pow(unsigned long long a, unsigned long long b) {
  unsigned long long ans = 1;
  while (b) {
    if (b & 1) ans = (ans * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return ans % mod;
}
unsigned long long inv(unsigned long long x) {
  return fast_pow(x, mod - 2) % mod;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<unsigned long long> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  sort(v.begin(), v.end());
  vector<unsigned long long> pref(n + 1);
  for (int i = 0; i < n; i++) {
    pref[i + 1] = pref[i] + v[i];
  }
  for (int i = 1; i <= m; i++) {
    unsigned long long a, b;
    cin >> a >> b;
    int pos = lower_bound(v.begin(), v.end(), b) - v.begin();
    int big = n - pos;
    if (big < a) {
      cout << 0 << endl;
      continue;
    }
    unsigned long long small_damage =
        (((big + 1 - a) * inv(big + 1)) % mod * ((pref[pos]) % mod)) % mod;
    unsigned long long big_damage =
        (((big - a) * inv(big)) % mod * ((pref[n] - pref[pos]) % mod)) % mod;
    cout << (small_damage + big_damage) % mod << endl;
  }
}
