#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
const int mod = 998244353;
int mypow(int a, int b) {
  int ret = 1;
  for (; b; b >>= 1, a = 1ll * a * a % mod) {
    if (b & 1) {
      ret = 1ll * ret * a % mod;
    }
  }
  return ret;
}
int inv(int a) { return mypow(a, mod - 2); }
int n, m, d[maxn];
long long sd[maxn];
long long sum(int l, int r) { return (sd[r] - sd[l] + mod) % mod; }
int main(int argc, char const *argv[]) {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &d[i]);
  }
  sort(d, d + n);
  for (int i = 0; i < n; ++i) {
    sd[i + 1] = sd[i] + d[i];
  }
  for (int i = 0; i < m; ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    int cnt = (d + n) - lower_bound(d, d + n, b);
    int res = 0;
    if (cnt >= a) {
      res = 1ll * (cnt - a) * inv(cnt) % mod * sum(n - cnt, n) % mod;
      res += 1ll * (cnt - a + 1) * inv(cnt + 1) % mod * sum(0, n - cnt) % mod;
      res %= mod;
    }
    printf("%d\n", res);
  }
  return 0;
}
