#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
const long long INF = -(long long)1e10;
long long power(long long x, long long a) {
  if (a == 0) return (1);
  long long z = power(x, a / 2);
  z = (z * z) % mod;
  if (a % 2) z = (z * x) % mod;
  return (z);
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<long long> strength(n);
  vector<pair<int, long long>> shield;
  for (int i = 0; i < n; i++) cin >> strength[i];
  sort(strength.begin(), strength.end());
  vector<long long> pfx_sum(n + 1);
  for (int i = 1; i <= n; i++) {
    pfx_sum[i] = strength[i - 1] + pfx_sum[i - 1];
    pfx_sum[i] %= mod;
  }
  for (int i = 0; i < m; i++) {
    int a;
    long long b;
    cin >> a >> b;
    shield.push_back({a, b});
  }
  for (int i = 0; i < m; i++) {
    int g = strength.end() -
            lower_bound(strength.begin(), strength.end(), shield[i].second);
    int s = n - g, a = shield[i].first;
    if (g < a) {
      cout << 0 << endl;
      continue;
    }
    long long ans =
        ((((g - a + 1) * power((long long)g + 1, mod - 2)) % mod * pfx_sum[s]) %
             mod +
         ((((g - a) * power((long long)g, mod - 2)) % mod) *
          (pfx_sum[n] - pfx_sum[s])) %
             mod) %
        mod;
    if (ans < 0) ans += mod;
    cout << ans << endl;
  }
}
