#include <bits/stdc++.h>
using namespace std;
template <typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;
const int N = 2e5 + 5, M = 998244353;
int n, m;
long long d[N], a[N], b[N], pref[N];
long long powmod(long long a, long long b) {
  long long ans = 1;
  while (b > 0) {
    if (b & 1) {
      ans = (ans * a) % M;
    }
    b /= 2;
    a = (a * a) % M;
  }
  return ans;
}
long long modinv(long long a) { return powmod(a, M - 2); }
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  for (int i = (1); i < (n + 1); i++) {
    cin >> d[i];
  }
  sort(d + 1, d + n + 1);
  for (int i = (1); i < (n + 1); i++) {
    pref[i] = (d[i] + pref[i - 1]) % M;
  }
  for (int i = (0); i < (m); i++) {
    cin >> a[i] >> b[i];
    int idx = lower_bound(d + 1, d + n + 1, b[i]) - d;
    long long B = n - idx + 1;
    if (a[i] > B) {
      cout << 0 << '\n';
      continue;
    } else if (B == 0) {
      cout << pref[n] << '\n';
      continue;
    }
    long long ans =
        ((((B - a[i]) * (pref[n] - pref[idx - 1])) % M) * modinv(B)) % M;
    if (B < n) {
      ans = (ans + (((B + 1 - a[i]) * modinv(B + 1)) % M) * pref[idx - 1]) % M;
    }
    cout << ans << '\n';
  }
}
