cswork / OAOpen practice workspace

AmazonOA #128

Count Ways to Select Fleet

Estimated EasyJudge-ready

Topics (AI-labelled)Bits & Math

Two-wheel and four-wheel vehicles are available in unlimited supply. For each total number of wheels, count the distinct combinations of the numbers of the two vehicle types.

Input

The first line contains n (1..100000), and the second line contains n wheel totals (1..10⁹).

Output

Output n integers in input order.

Example 1

Input:

3
6 3 2

Output:

2 0 1

Example 2

Input:

3
4 5 6

Output:

2 0 2

Example 3

Input:

2
1 8

Output:

0 3

Example notes

Example 1: 6 has the two options (3,0) and (1,1), 3 has no solution, and 2 has only (1,0), so output 2 0 1. Example 2: 4 and 6 have two options each, and 5 has no solution. Example 3: 1 has no solution; 8 has three options with 0, 1 or 2 four-wheelers, so output 0 3.

Editorial

Loading solution…