#include <bits/stdc++.h>
const double pi = acos(-1.0);
const double eps = 1e-9;
using namespace std;
const long long MOD = 998244353;
const int N = 2e5 + 10;
long long mult(long long x, long long y) {
  x %= MOD;
  y %= MOD;
  return x * y % MOD;
}
long long bin_pow(long long x, long long n) {
  long long res = 1;
  while (n) {
    if (n & 1) res = mult(res, x);
    n >>= 1;
    x = mult(x, x);
  }
  return res;
}
long long inv(long long x) { return bin_pow(x, MOD - 2); }
long long add(long long x, long long y) {
  x += y;
  if (x >= MOD) x -= MOD;
  return x;
}
int n, m;
long long d[N], prefD[N];
long long get(int l, int r) { return (prefD[r] - prefD[l] + MOD) % MOD; }
void solve() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> d[i];
  }
  sort(d, d + n);
  for (int i = 1; i <= n; i++) {
    prefD[i] = prefD[i - 1] + d[i - 1];
  }
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    int cnt = d + n - lower_bound(d, d + n, b);
    int res = 0;
    if (cnt >= a) {
      res = mult(mult(cnt - a, inv(cnt)), get(n - cnt, n));
      res = add(res, mult(mult(cnt - a + 1, inv(cnt + 1)), get(0, n - cnt)));
    }
    cout << res << "\n";
  }
}
int main() {
  ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
  cout.setf(ios::fixed), cout.precision(9);
  int step = 1;
  for (int i = 0; i < step; i++) {
    solve();
  }
}
