#include <bits/stdc++.h>
using namespace std;
const long long inf = 8e18;
const long long maxn = 2e5 + 10;
const long long mod = 998244353;
struct node {
  long long a, b, id;
} a[maxn];
long long n, m, d[maxn], sumall, ans[maxn];
template <class T>
void read(T &x) {
  T res = 0, f = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) {
    res = (res << 3) + (res << 1) + c - '0';
    c = getchar();
  }
  x = res * f;
}
long long qpow(long long a, long long p, long long mod) {
  long long ans = 1;
  a = a % mod;
  while (p) {
    if (p & 1) ans = (ans * a) % mod;
    p >>= 1;
    a = (a * a) % mod;
  }
  return ans;
}
bool cmp(node a, node b) { return a.b > b.b; }
int main() {
  int T = 1;
  while (T--) {
    read(n), read(m);
    for (long long i = 1; i <= n; i++)
      read(d[i]), sumall = (sumall + d[i]) % mod;
    for (long long i = 1; i <= m; i++) read(a[i].a), read(a[i].b), a[i].id = i;
    sort(d + 1, d + 1 + n, greater<long long>());
    sort(a + 1, a + 1 + m, cmp);
    long long sum = 0, pos = 1;
    for (long long i = 1; i <= m; i++) {
      while (pos <= n && d[pos] >= a[i].b) {
        sum = (sum + d[pos]) % mod, ++pos;
      }
      if (pos - 1 >= a[i].a) {
        ans[a[i].id] = ((sum * qpow(pos - 1, mod - 2, mod) % mod *
                         (pos - 1 - a[i].a) % mod) +
                        ((sumall - sum + mod) * qpow(pos, mod - 2ll, mod) %
                         mod * (pos - a[i].a) % mod)) %
                       mod;
      }
    }
    for (long long i = 1; i <= m; i++) cout << ans[i] << endl;
  }
  return 0;
}
