A drone light-show operator wants every drone in a formation of n drones to hover at its own altitude offset (in meters) relative to a shared reference altitude. Each drone's offset must be different from every other drone's offset, yet the formation's average altitude must stay exactly at the reference altitude, which means all n offsets must sum to exactly zero. A positive offset flies above the reference altitude, a negative offset flies below it, and an offset of exactly 0 is allowed for at most one drone (since offsets must be distinct). Given the number of drones n, output any n distinct integers that sum to 0.
A single line containing one integer n.
Print n space-separated integers, all pairwise distinct, whose sum is exactly 0. Any valid assignment satisfying the constraints below is accepted.
Example 1
Input
1
Expected
0
Explanation
With only one drone, its offset must equal the sum of the whole formation, which must be 0. Since a single value trivially satisfies 'all distinct', the only valid output is 0.
Example 2
Input
4
Expected
1 -1 2 -2
Explanation
Four distinct offsets 1, -1, 2, -2 are pairwise different, and their sum is 1 + (-1) + 2 + (-2) = 0, so this satisfies both requirements (any other valid set of 4 distinct integers summing to 0 would also be accepted).
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →