#include <bits/stdc++.h>
using namespace std;
template <class T1, class T2>
ostream &operator<<(ostream &os, pair<T1, T2> &p);
template <class T>
ostream &operator<<(ostream &os, vector<T> &v);
template <class T>
ostream &operator<<(ostream &os, set<T> &v);
template <class T1, class T2>
ostream &operator<<(ostream &os, map<T1, T2> &v);
const int N = 2e6 + 5;
const long long mod = 998244353;
long long bigmod(long long a, long long b) {
  a %= mod;
  long long ans = 1;
  while (b > 0) {
    if (b & 1) {
      ans = (ans * a) % mod;
    }
    a = (a * a) % mod;
    b >>= 1;
  }
  return ans;
}
long long add(long long a, long long b) {
  a += b;
  if (a >= mod) a -= mod;
  return a;
}
long long sub(long long a, long long b) {
  a -= b;
  if (a < 0) a += mod;
  return a;
}
long long gun(long long a, long long b) { return (a * b) % mod; }
long long vag(long long a, long long b) {
  return (a * bigmod(b, mod - 2)) % mod;
}
long long get_sum(long long l, long long r, vector<long long> &prefix) {
  if (r < 0) return 0;
  long long ans = prefix[r];
  if (l != 0) ans = sub(ans, prefix[l - 1]);
  return ans;
}
void TEST_CASES(int cas) {
  long long n, m;
  cin >> n >> m;
  vector<long long> a(n);
  vector<long long> prefix(n);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  prefix[0] = a[0];
  for (long long i = 1; i < n; i++) {
    prefix[i] = add(prefix[i - 1], a[i] % mod);
  }
  while (m--) {
    long long aa, b;
    cin >> aa >> b;
    long long id = lower_bound(a.begin(), a.end(), b) - a.begin();
    long long koto = n - id;
    if (koto < aa) {
      cout << 0 << "\n";
      continue;
    }
    long long ans = 0;
    long long prob_big = sub(1, vag(aa, koto));
    long long prob_small = sub(1, vag(aa, koto + 1));
    long long sum1 = get_sum(0, id - 1, prefix);
    long long sum2 = get_sum(id, n - 1, prefix);
    ans = add(gun(prob_big, sum2), gun(prob_small, sum1));
    cout << ans << "\n";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int t = 1, cas = 0;
  while (t--) {
    TEST_CASES(++cas);
  }
  return 0;
}
template <class T1, class T2>
ostream &operator<<(ostream &os, pair<T1, T2> &p) {
  os << "{" << p.first << ", " << p.second << "} ";
  return os;
}
template <class T>
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "[ ";
  for (int i = 0; i < v.size(); i++) {
    os << v[i] << " ";
  }
  os << " ]";
  return os;
}
template <class T>
ostream &operator<<(ostream &os, set<T> &v) {
  os << "[ ";
  for (T i : v) {
    os << i << " ";
  }
  os << " ]";
  return os;
}
template <class T1, class T2>
ostream &operator<<(ostream &os, map<T1, T2> &v) {
  for (auto i : v) {
    os << "Key : " << i.first << " , Value : " << i.second << endl;
  }
  return os;
}
