Public Judge

pjudge

时间限制: 2 s 内存限制: 1024 MB 总分: 7 可 Hack ✓

#21632. 【PER #1】Average Score

统计

There are $n$ cakes, where the $i$-th cake has a weight of $a_i$.

You want to divide these $n$ cakes into three parts such that the sum of weights in each part is equal.

However, you find that the cakes cannot be cut, so you must settle for minimizing the range, which is the difference between the maximum sum of weights and the minimum sum of weights among the three parts.

Input

The first line contains a positive integer $n$.

The second line contains $n$ positive integers $a_1, a_2, \dots, a_n$.

Output

Output $n$ integers, each of which must be one of $\{1, 2, 3\}$, representing which part each cake is assigned to.

If there are multiple solutions that minimize the range, you may output any one of them.

Examples

Input 1

5
2 3 1 4 2

Output 1

3 2 2 1 3

Note 1

The sums of the weights of the three parts are:

  • $4$
  • $3 + 1 = 4$
  • $2 + 2 = 4$

Therefore, the range of this scheme is $0$.

Input 2

6
3 2 5 3 4 2

Output 2

2 3 1 2 3 1

Note 2

The sums of the weights of the three parts are:

  • $5 + 2 = 7$
  • $3 + 3 = 6$
  • $2 + 4 = 6$

Therefore, the range of this scheme is $1$.

Input 3

See the provided files.

Constraints

For all data, it is guaranteed that $3 \le n \le 25$ and $1 \le a_i \le 10^7$.

Subtask ID Additional Constraints Score
$1$ $100$

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.