#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using db = double;
using vi = vector<int>;
const int inf = 0x3f3f3f3f;
const db eps = 1e-8;
const int mod = 998244353;
ll qpow(ll a, ll b) {
  ll ret = 1;
  while (b) {
    if (b & 1) ret = ret * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return ret;
}
const int maxn = 2e5 + 7;
int n, m;
int d[maxn], a[maxn], b[maxn];
ll inv(ll a) { return qpow(a, mod - 2) % mod; }
ll pre[maxn];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 0; i < n; ++i) cin >> d[i];
  sort(d, d + n);
  for (int i = 0; i < n; ++i) pre[i + 1] = pre[i] + d[i];
  for (int q = 0; q < m; q++) {
    int a, b;
    cin >> a >> b;
    int id = lower_bound(d, d + n, b) - d;
    int big = n - id;
    ll big_num = pre[n] - pre[id];
    ll small_num = pre[id];
    if (a > big || a == n) {
      cout << "0\n";
      continue;
    }
    ll ans1 = big_num % mod * (big - a) % mod * inv(big) % mod;
    ll ans2 = small_num % mod * (big + 1 - a) % mod * inv(big + 1) % mod;
    cout << (ans1 + ans2) % mod << "\n";
  }
  return 0;
}
