← Back to Problems
Circular Trading
Easy standard Graphs & Networks Combinatorics
Time limit: 2 s per test  ·  Memory: 256 MB

A trading venue has n participants. Any two participants may maintain a bilateral trading relationship. The venue's surveillance rules forbid circular trading among any three parties: no three participants may all pairwise trade with each other.

Compute the maximum possible number of bilateral trading relationships, as an exact integer. Answer q independent queries.

Input

The first line contains q. Each of the next q lines contains one integer n.

Output

For each query, output the maximum number of bilateral trading relationships on its own line.

Constraints

1 <= q <= 10^4 1 <= n <= 10^18

Scoring

This is a standard problem: a submission scores full points if it produces the correct output for every test case, and zero otherwise.

Example

input
4
2
3
5
10
output
1
2
6
25
Python 3.13 i Execution environment Isolated microVM · 1 vCPU · no internet access Time and memory limits are set per problem Available packages numpy 2.5.0scipy 1.18.0pandas 3.0.0scikit-learn 1.9.0statsmodels 0.15.0cvxpy 1.9.2