#include <bits/stdc++.h>
using namespace std;
long long n, a, b, x;
long long bin(int v) {
  long long l = 1, r = v, mid, ans = 0, res = 0, t;
  while (l <= r) {
    mid = (l + r) / 2;
    if (mid * a / b > ans) {
      ans = mid * a / b;
      t = ans * b;
      t = ceil((t + 0.0) / a);
      res = t;
    }
    l = mid + 1;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> a >> b;
  for (int i = 1; i <= n; i++) {
    cin >> x;
    cout << x - bin(x) << " ";
  }
}
