#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
const int maxm = 1e6 + 10;
const int inf = 0x3f3f3f3f;
const long long mod = 998244353;
const double eps = 1e-7;
int dir[4][2] = {{0, 1}, {0, -1}, {-1, 0}, {1, 0}};
long long n, m;
long long d[maxn];
long long sum[maxn];
long long fast_pow(long long a, long long k) {
  long long ans = 1;
  a = a % mod;
  while (k != 0) {
    if (k & 1) ans = (ans * a) % mod;
    k >>= 1;
    a = (a * a) % mod;
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> d[i];
  sort(d + 1, d + 1 + n);
  for (int i = 1; i <= n; i++) sum[i] = sum[i - 1] + d[i];
  while (m--) {
    long long a, b;
    cin >> a >> b;
    long long pos = lower_bound(d + 1, d + 1 + n, b) - d;
    long long ans = 0;
    long long cnt = n - pos + 1;
    if (a > cnt)
      cout << 0;
    else {
      long long tmp = (((sum[n] - sum[pos - 1]) % mod) * (cnt - a)) % mod;
      tmp *= fast_pow(cnt, mod - 2);
      tmp %= mod;
      ans += tmp;
      ans %= mod;
      tmp = (sum[pos - 1] % mod) * (cnt - a + 1) % mod;
      tmp %= mod;
      tmp *= fast_pow(cnt + 1, mod - 2);
      tmp %= mod;
      ans += tmp;
      ans %= mod;
      cout << ans;
    }
    cout << endl;
  }
  return ~~(0 - 0);
}
