#include <bits/stdc++.h>
using namespace std;
const int M = 998244353;
int safe(long long x) {
  int y = (int)(x % M);
  if (y < 0) {
    y += M;
  }
  return y;
}
int mul(long long x, long long y) {
  int x2 = safe(x), y2 = safe(y);
  return (int)((long long)(x2)*y2 % M);
}
int exp(long long x, long long y) {
  assert(y >= 0);
  int ans = 1, z = safe(x);
  for (; y != 0; y >>= 1) {
    if ((y & 1) == 1) {
      ans = mul(ans, z);
    }
    z = mul(z, z);
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m;
  cin >> n >> m;
  vector<int> d(n);
  vector<long long> pd(n + 1);
  for (int i = 0; i < n; i++) {
    cin >> d[i];
  }
  sort(d.begin(), d.end());
  for (int i = 0; i < n; i++) {
    pd[i + 1] = pd[i] + d[i];
  }
  while (m-- > 0) {
    int ai, bi;
    cin >> ai >> bi;
    int small = (int)(lower_bound(d.begin(), d.end(), bi) - d.begin()),
        big = n - small;
    if (ai > big || ai == n) {
      cout << 0 << '\n';
      continue;
    }
    long long big_sum = pd[n] - pd[small], small_sum = pd[small];
    cout << (mul(big_sum, mul(big - ai, exp(big, M - 2))) +
             mul(small_sum, mul(big + 1 - ai, exp(big + 1, M - 2)))) %
                M
         << '\n';
  }
  return 0;
}
