#include <bits/stdc++.h>
using LL = long long;
constexpr int P = 998244353;
LL powP(LL n, LL k) {
  LL acc = 1LL;
  while (k) {
    if (k & 1) acc = acc * n % P;
    n = n * n % P;
    k >>= 1;
  }
  return acc;
}
LL inv(LL n) { return powP(n, P - 2); }
int main() {
  using namespace std;
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m;
  cin >> n >> m;
  vector<int> evil = vector<int>(n);
  for (int& d : evil) cin >> d;
  sort(evil.begin(), evil.end());
  vector<int> psums = vector<int>(n + 1, 0);
  for (int i = 0; i < n; ++i) psums[i + 1] = (psums[i] + evil[i]) % P;
  while (m--) {
    int a, b;
    cin >> a >> b;
    LL OKs = lower_bound(evil.begin(), evil.end(), b) - evil.begin();
    LL issues = n - OKs;
    LL ans = 0LL;
    if (issues >= a) {
      LL numerator = issues - a + 1;
      LL denominator = issues + 1;
      LL w = psums[OKs];
      ans += (numerator * w % P) * inv(denominator) % P;
    }
    if (issues > a) {
      LL numerator = issues - a;
      LL denominator = issues;
      LL w = psums[n] - psums[OKs] + P;
      ans += (numerator * w % P) * inv(denominator) % P;
    }
    cout << (ans % P) << '\n';
  }
  return 0;
}
