#include <bits/stdc++.h>
using namespace std;
long long put(long long baza, long long exp) {
  if (exp == 0) return 1;
  long long ans = put(baza, exp / 2);
  ans *= ans;
  ans %= 998244353;
  if (exp % 2) {
    ans *= baza;
    ans %= 998244353;
  }
  return ans;
}
long long n, m, i, cbig, csma, ans, p, big, a, b, sum;
long long v[200005];
long long s[200005];
int main() {
  cin >> n >> m;
  for (i = 1; i <= n; i++) cin >> v[i];
  sort(v + 1, v + n + 1);
  for (i = 1; i <= n; i++) {
    s[i] = s[i - 1] + v[i];
    s[i] %= 998244353;
  }
  for (i = 1; i <= m; i++) {
    cin >> a >> b;
    p = lower_bound(v + 1, v + n + 1, b) - v;
    big = n - p + 1;
    if (a > big) {
      cout << "0\n";
      continue;
    }
    cbig = 1;
    cbig -= (a * put(big, 998244353 - 2)) % 998244353;
    if (cbig < 0) cbig += 998244353;
    csma = 1;
    csma -= (a * put(big + 1, 998244353 - 2)) % 998244353;
    if (csma < 0) csma += 998244353;
    sum = (s[n] - s[p - 1]) % 998244353;
    if (sum < 0) sum += 998244353;
    ans = (sum * cbig) % 998244353;
    ans += (s[p - 1] * csma) % 998244353;
    if (ans >= 998244353) ans -= 998244353;
    cout << ans << '\n';
  }
  return 0;
}
