#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, b, x, t2;
  double ans, s, t1;
  scanf("%d%d%d", &n, &a, &b);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x);
    if (a % b == 0)
      printf("0 ");
    else {
      t1 = 1.0 * b / a;
      t2 = (int)(x / t1);
      s = 1.0 * t2 * 1.0 / a * 1.0 * b * 1.0;
      ans = 1.0 * (x - s);
      printf("%d ", (int)ans);
    }
  }
  return 0;
}
