#include <bits/stdc++.h>
using namespace std;
const int MOD = 998244353;
const int N = 200000;
long long mod_pow(long long a, long long n) {
  long long ans = 1;
  for (; n > 0; n >>= 1) {
    if (n & 1) ans = ans * a % MOD;
    a = a * a % MOD;
  }
  return ans;
}
void solve() {
  long long n, m;
  cin >> n >> m;
  vector<long long> d(n);
  for (long long i = 0; i < n; i++) cin >> d[i];
  sort(d.begin(), d.end());
  vector<long long> p(n + 1), s(n + 1);
  for (long long i = 1; i <= n; i++) p[i] = (p[i - 1] + d[i - 1]) % MOD;
  for (long long i = n - 1; i >= 0; i--) s[i] = (s[i + 1] + d[i]) % MOD;
  while (m--) {
    long long a, b;
    cin >> a >> b;
    long long i = lower_bound(d.begin(), d.end(), b) - d.begin();
    long long ans =
        (s[i] * max(0ll, n - i - a) % MOD * mod_pow(n - i, MOD - 2) +
         p[i] * max(0ll, n - i - a + 1) % MOD * mod_pow(n - i + 1, MOD - 2)) %
        MOD;
    cout << ans << "\n";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}
