#include #include using namespace std; const int N = 5010; int dp; int main() { int T; scanf("%d", &T); while (T--) { int n; scanf("%d", &n); dp = 0; for (int i = 2; i <= n; ++i) dp = (dp + n - i + 1) % i; printf("%d\n", dp + 1); } return 0; }