#include <bits/stdc++.h>
using namespace std;
long long bigmod(long long x, int p) {
  long long res = 1;
  while (p) {
    if (p & 1) res = (res * x) % 998244353;
    x = (x * x) % 998244353;
    p >>= 1;
  }
  return res;
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<long long> d(n), pref(n);
  for (int i = 0; i < n; i++) cin >> d[i];
  sort(d.begin(), d.end());
  pref[0] = d[0];
  for (int i = 1; i < n; i++) pref[i] = (pref[i - 1] + d[i]) % 998244353;
  while (m--) {
    int a, b;
    cin >> a >> b;
    int x = lower_bound(d.begin(), d.end(), b) - d.begin();
    int big = n - x;
    if (big < a) {
      cout << 0 << "\n";
      continue;
    }
    long long big_total = (pref[n - 1] - (x > 0 ? pref[x - 1] : 0)) % 998244353;
    (big_total += 998244353) %= 998244353;
    long long ans = (big_total * (big - a)) % 998244353;
    ans = (ans * bigmod(big, 998244353 - 2)) % 998244353;
    long long tmp = ((x > 0 ? pref[x - 1] : 0) * (big + 1 - a)) % 998244353;
    tmp = (tmp * bigmod(big + 1, 998244353 - 2)) % 998244353;
    ans = (ans + tmp) % 998244353;
    cout << ans << "\n";
  }
  return 0;
}
