#include <bits/stdc++.h>
using namespace std;
inline long long Qpow(long long a, long long p) {
  if (p == 0) return 1;
  long long t = Qpow(a, p / 2);
  t = t * t % 998244353;
  if (p % 2 == 1) t = t * a % 998244353;
  return t;
}
inline long long inv(long long a) { return Qpow(a, 998244353 - 2); }
long long n, m;
long long d[200005], sum[200005], a[200005], b[200005];
inline long long S(long long l, long long r) {
  return (sum[r] - sum[l - 1] + 998244353) % 998244353;
}
inline long long lower(long long x) {
  long long l = 1, r = n, ans = 0;
  while (l <= r) {
    long long mid = (l + r) / 2;
    if (d[mid] < x)
      ans = mid, l = mid + 1;
    else
      r = mid - 1;
  }
  return ans;
}
signed main() {
  cin >> n >> m;
  for (long long i = 1; i <= n; i++) scanf("%lld", &d[i]);
  sort(d + 1, d + 1 + n);
  for (long long i = 1; i <= n; i++) sum[i] = (sum[i - 1] + d[i]) % 998244353;
  for (long long i = 1; i <= m; i++) scanf("%lld%lld", &a[i], &b[i]);
  for (long long i = 1; i <= m; i++) {
    long long mid = lower(b[i]);
    long long num = n - mid;
    long long ans = 0;
    if (num > 0 && num >= a[i]) {
      ans +=
          S(1, mid) * (num - a[i] + 1) % 998244353 * inv(num + 1) % 998244353;
      ans %= 998244353;
    }
    num--;
    if (num > 0 && num >= a[i]) {
      ans += S(mid + 1, n) * (num - a[i] + 1) % 998244353 * inv(num + 1) %
             998244353;
      ans %= 998244353;
    }
    printf("%lld\n", ans);
  }
  return 0;
}
