#include <bits/stdc++.h>
using namespace std;
const int Mod = 998244353;
int n, m;
int a[200010];
long long sum[200010];
inline long long ksm(long long x, long long y) {
  long long res = 1;
  while (y) {
    if (y & 1) res *= x, res %= Mod;
    x *= x;
    x %= Mod;
    y >>= 1;
  }
  return res;
}
inline long long inv(long long x) { return ksm(x, Mod - 2); }
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; i++) sum[i] = sum[i - 1] + a[i];
  while (m--) {
    int hp, lv;
    scanf("%d%d", &hp, &lv);
    int pos = lower_bound(a + 1, a + n + 1, lv) - a;
    int cnt = (n - pos + 1);
    if (cnt < hp) {
      puts("0");
      continue;
    }
    long long ans1 = sum[pos - 1] % Mod, ans2 = (sum[n] - sum[pos - 1]) % Mod;
    long long p1 = ((1 - hp * inv(cnt + 1) % Mod) + Mod) % Mod,
              p2 = ((1 - hp * inv(cnt) % Mod) + Mod) % Mod;
    printf("%lld\n", (ans1 * p1 % Mod + ans2 * p2 % Mod) % Mod);
  }
  return 0;
}
