#include <bits/stdc++.h>
using namespace std;
long long mod = 998244353;
long long inv(long long a, long long b = mod) {
  return 1 < a ? b - inv(b % a, a) * b / a : 1;
}
long long mul(long long a, long long b) { return (a * b) % mod; }
long long add(long long a, long long b) { return (a + b) % mod; }
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  vector<long long> d(n);
  for (int i = 0; i < n; ++i) cin >> d[i];
  sort(d.begin(), d.end());
  vector<long long> psum(n + 1);
  for (int i = 1; i <= n; ++i) psum[i] = add(psum[i - 1], d[i - 1]);
  auto get = [&](int l, int r) { return (psum[r] - psum[l] + mod) % mod; };
  for (int i = 0; i < m; ++i) {
    long long a, b;
    cin >> a >> b;
    long long res = 0;
    long long begin_idx = lower_bound(d.begin(), d.end(), b) - d.begin();
    long long count_big = n - begin_idx;
    res = add(res, mul(mul(max(count_big - a, 0ll), inv(count_big)),
                       get(begin_idx, n)));
    res = add(res, mul(mul(max(count_big - a + 1, 0ll), inv(count_big + 1)),
                       get(0, begin_idx)));
    cout << res << '\n';
  }
}
