#include <bits/stdc++.h>
using namespace std;
long long power[200005];
long long fact[200005];
int modInverse(int a, int m) {
  int m0 = m;
  int y = 0, x = 1;
  if (m == 1) return 0;
  while (a > 1) {
    int q = a / m;
    int t = m;
    m = a % m, a = t;
    t = y;
    y = x - q * y;
    x = t;
  }
  if (x < 0) x += m0;
  return x;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  long long n, m;
  cin >> n >> m;
  long long d[n];
  power[0] = 1;
  fact[0] = 1;
  for (long long i = 1; i <= 200000; i++) {
    power[i] = power[i - 1] * 2;
    power[i] = power[i] % 998244353;
    fact[i] = fact[i - 1] * i;
    fact[i] = fact[i] % 998244353;
  }
  long long pre[n + 1];
  pre[0] = 0;
  for (long long i = 0; i < n; i++) {
    cin >> d[i];
  }
  sort(d, d + n);
  for (long long i = 0; i < n; i++) {
    pre[i + 1] = pre[i] + d[i];
    pre[i + 1] = pre[i + 1] % 998244353;
  }
  for (long long i = 0; i < m; i++) {
    long long a, b;
    cin >> a >> b;
    long long p1 = lower_bound(d, d + n, b) - d;
    long long big = n - p1;
    long long p2 = big;
    if (p2 < a) {
      cout << 0 << "\n";
      continue;
    }
    long long num1 = (big - a) * (pre[n] - pre[n - p2]);
    num1 = num1 % 998244353;
    if (num1 < 0) {
      num1 += 998244353;
    }
    num1 *= (big + 1);
    num1 = num1 % 998244353;
    long long num2 = (big + 1 - a) * (pre[p1]);
    num2 = num2 % 998244353;
    num2 *= big;
    num2 = num2 % 998244353;
    long long sum = num1 + num2;
    sum = sum * modInverse(big, 998244353);
    sum = sum % 998244353;
    sum = sum * modInverse((big + 1), 998244353);
    sum = sum % 998244353;
    cout << sum << "\n";
  }
}
