#include <bits/stdc++.h>
using namespace std;
bool endline = false;
template <class T>
istream& operator>>(istream& inp, vector<T>& v) {
  for (auto& it : v) inp >> it;
  return inp;
}
template <class T>
ostream& operator<<(ostream& out, vector<T>& v) {
  for (auto& it : v) out << it << (endline ? "\n" : " ");
  return out;
}
template <class T, class U>
istream& operator>>(istream& inp, pair<T, U>& v) {
  inp >> v.first >> v.second;
  return inp;
}
template <class T, class U>
ostream& operator<<(ostream& out, pair<T, U>& v) {
  out << v.first << ' ' << v.second;
  return out;
}
const int mod1 = 998244353, mod = 1e9 + 7;
const int MAXN = 2e5 + 6, MAXM = 5e5 + 5;
const int inf = 2e9;
const long long linf = 1e18;
long long binpow(long long a, long long x) {
  long long r = 1;
  while (x) {
    if (x & 1) r = (r * a) % mod1;
    a = (a * a) % mod1;
    x >>= 1;
  }
  return r;
}
long long inv(long long x) { return binpow(x, mod1 - 2); }
long long d[MAXN], pref[MAXN], a, b, n, m;
void Solve() {
  cin >> n >> m;
  for (long long i = 0; i < n; i++) cin >> d[i];
  sort(d, d + n);
  for (long long i = 0; i < n; i++) pref[i + 1] = pref[i] + d[i];
  while (m--) {
    cin >> a >> b;
    long long sml = lower_bound(d, d + n, b) - d;
    long long big = n - sml;
    long long btot = (pref[n] - pref[sml]) % mod1;
    long long stot = pref[sml] % mod1;
    if (a > big) {
      cout << 0 << endl;
    } else if (!big) {
      cout << pref[n] << endl;
    } else {
      long long ans = (big - a) * inv(big) % mod1 * btot % mod1;
      ans = (ans + (big + 1 - a) * inv(big + 1) % mod1 * stot % mod1) % mod1;
      cout << ans << endl;
    }
  }
}
signed main() {
  if (fopen(""
            ".inp",
            "r")) {
    freopen(
        ""
        ".inp",
        "r", stdin);
    freopen(
        ""
        ".out",
        "w", stdout);
  };
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long TC = 1;
  while (TC--) Solve();
  return 0;
}
