#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 200005;
const long long MOD = 998244353;
const int INF = 0x3f3f3f3f;
long long binpow(long long a, long long b) {
  long long r = 1;
  while (b) {
    if (b & 1) r = r * a % MOD;
    b >>= 1;
    a = a * a % MOD;
  }
  return r;
}
long long d[N];
long long s, t;
long long ans[N];
vector<pair<long long, pair<int, int> > > v;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    cin >> d[i];
    t += d[i];
  }
  t %= MOD;
  sort(d + 1, d + n + 1);
  for (int i = 1; i <= m; ++i) {
    int a, b;
    cin >> a >> b;
    v.push_back({b, {a, i}});
  }
  sort(v.rbegin(), v.rend());
  int cnt = 0;
  for (auto& x : v) {
    while (d[n] >= x.first) {
      ++cnt;
      s += d[n];
      t -= d[n];
      --n;
      t %= MOD;
      s %= MOD;
    }
    ans[x.second.second] =
        s * max(0, cnt - x.second.first) % MOD * binpow(cnt, MOD - 2) % MOD +
        t * max(0, cnt + 1 - x.second.first) % MOD * binpow(cnt + 1, MOD - 2) %
            MOD;
    ans[x.second.second] = (ans[x.second.second] % MOD + MOD) % MOD;
  }
  for (int i = 1; i <= m; ++i) cout << ans[i] << '\n';
}
