| Contests - ACM Student Chapter - PSUT |
|---|
| Private |
| Spectator |
| PSUT Programming Contest 2026 |
|---|
| Finished |
Asem recently learned about coprime numbers and immediately started hating them.
Given an integer $$$N$$$, Asem wants to find the largest integer $$$M$$$ such that $$$1 \le M \lt N$$$ and $$$M$$$ is NOT coprime with $$$N$$$.
Two integers are said to be coprime if their greatest common divisor is equal to $$$1$$$.
Help Asem find the answer.
The first line contains a single integer $$$t$$$ $$$(1 \le t \le 10^4)$$$ – the number of test cases.
Each test case consists of a single integer $$$N$$$ $$$(2 \le N \le 10^6)$$$.
For each test case, print a single integer – the maximum integer $$$M$$$ such that $$$1 \le M \lt N$$$ and $$$\gcd(M, N) \gt 1$$$.
If no such integer exists, print $$$-1$$$.
3236
-1-14
| Name |
|---|

