#include <bits/stdc++.h>
using namespace std;
inline int fread() {
  char ch = getchar();
  int x = 0, f = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &ptt) {
  os << "(" << ptt.first << ", " << ptt.second << ")";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vt) {
  os << "{";
  for (int i = 0; i < vt.size() - 1; i++) {
    os << vt[i] << ", ";
  }
  os << vt[vt.size() - 1] << "}";
  return os;
}
long long fpow(long long x, long long a) {
  if (a == 0) return 1;
  if (a == 1) return x;
  long long tmp = fpow(x, a >> 1);
  tmp = (tmp * tmp) % 998244353;
  if (a & 1) {
    tmp = (tmp * x) % 998244353;
  }
  return tmp;
}
int n, m;
int d[200005];
long long s[200005];
int main(int argc, char *argv[]) {
  cin.tie(0);
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%d", d + i);
  }
  sort(d, d + n);
  for (int i = 1; i <= n; i++) {
    s[i] = s[i - 1] + d[i - 1];
    s[i] %= 998244353;
  }
  for (int i = 0; i < m; i++) {
    long long a, b;
    scanf("%lld%lld", &a, &b);
    int p = lower_bound(d, d + n, b) - d;
    long long k = n - p;
    if (k < a) {
      printf("0\n");
    } else {
      long long ans = 0;
      long long s1 = s[p];
      long long s2 = (s[n] - s1 + 998244353) % 998244353;
      ans += (s1 * (k - a + 1)) % 998244353 * fpow(k + 1, 998244353 - 2);
      ans %= 998244353;
      ans += (s2 * (k - a)) % 998244353 * fpow(k, 998244353 - 2);
      ans %= 998244353;
      printf("%lld\n", ans);
    }
  }
  return 0;
}
