#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
using namespace std;
template <typename T>
void etch(T V) {
  for (auto x : V) cout << x << ' ';
  cout << '\n';
}
vector<string> vec_splitter(string s) {
  s += ',';
  vector<string> res;
  while (!s.empty()) {
    res.push_back(s.substr(0, s.find(',')));
    s = s.substr(s.find(',') + 1);
  }
  return res;
}
void debug_out(vector<string> __attribute__((unused)) args,
               __attribute__((unused)) long long int idx,
               __attribute__((unused)) long long int LINE_NUM) {
  cerr << endl;
}
template <typename Head, typename... Tail>
void debug_out(vector<string> args, long long int idx, long long int LINE_NUM,
               Head H, Tail... T) {
  if (idx > 0)
    cerr << ", ";
  else
    cerr << "Line(" << LINE_NUM << ") ";
  stringstream ss;
  ss << H;
  cerr << args[idx] << " = " << ss.str();
  debug_out(args, idx + 1, LINE_NUM, T...);
}
const long long int MOD = 998244353;
const long long int N = 2e5 + 5;
const long long int INF = 1000111000111000111LL;
const long double EPS = 1e-12;
const long double PI = 3.141592653589793116;
long long int modular_exp(long long int base, long long int exp,
                          long long int mod) {
  long long int ans = 1;
  while (exp) {
    if (exp % 2) ans = ans % mod * base % mod;
    base = (base % mod * base % mod) % mod;
    exp /= 2;
    ans %= mod;
  }
  return ans;
}
long long int inv_mod(long long int base, long long int mod) {
  return modular_exp(base, mod - 2, mod);
}
long long int fact[N];
void pre_compute() {
  fact[0] = 1;
  for (long long int i = 1; i < N; i++) {
    fact[i] = i * fact[i - 1];
    fact[i] %= MOD;
  }
}
long long int nCr(long long int n, long long int r) {
  if (r >= n or r == 0) return 1;
  return ((fact[n] % MOD * inv_mod(fact[r], MOD) % MOD) *
          inv_mod(fact[n - r], MOD)) %
         MOD;
}
int32_t main() {
  std::ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n, m;
  cin >> n >> m;
  vector<long long int> d(n), pre(n, 0);
  for (long long int i = (0); i < (n); i++) {
    cin >> d[i];
  }
  sort((d).begin(), (d).end());
  for (long long int i = (0); i < (n); i++) {
    if (!i)
      pre[i] = d[i];
    else
      pre[i] += pre[i - 1] + d[i];
  }
  auto get_sum = [&](long long int l, long long int r) -> long long int {
    if (r < l or l < 0) return 0;
    if (!l)
      return pre[r];
    else
      return pre[r] - pre[l - 1];
  };
  while (m--) {
    long long int a, b;
    cin >> a >> b;
    long long int more = d.end() - lower_bound((d).begin(), (d).end(), b);
    long long int less = n - more;
    long long int expected_damage = 0;
    if (more > a) {
      long long int prob = ((more - a) * inv_mod(more, MOD)) % MOD;
      expected_damage += (prob * (get_sum(n - more, n - 1) % MOD)) % MOD;
      expected_damage %= MOD;
    }
    if (more >= a) {
      long long int prob = ((more + 1 - a) * inv_mod(more + 1, MOD)) % MOD;
      expected_damage += (prob * (get_sum(0, less - 1) % MOD)) % MOD;
      expected_damage %= MOD;
    }
    cout << expected_damage << '\n';
  }
  return 0;
}
