The Goal

Make more than 10,000 points.

  Rules

Players take turns.
The player receives 6 dice.

The player may choose to pass and score the points, or re-roll the dice.
To re-roll the dice, the player must keep at least one of the dice.
If a dice roll fails to score points, all accumulated points are lost.

Each 1 is worth 100 points and each 5 is worth 50 points. A three of a kind is worth 100 times the value of the number on the dice, except in the case of a three of 1s, which is worth 1,000 points.

  • A 5 is worth 50 points
  • A 1 is worth 100 points
  • Three 2s are worth 200 points
  • Three 3s are worth 300 points
  • Three 4s are worth 400 points
  • Three 5 are worth 500 points
  • Three 6 are worth 600 points
  • Three 1's worth 1,000 points

Four of a kind (four dice of the same value), five of a kind (five dice of the same value) and six of a kind (six dice of the same value) are incremented by the value of the corresponding three of a kind. For example, a three of 2 is worth 200 points, a four of 2 is worth 400, a five of 2 is worth 600 and a six of 2 is worth 800.

A sequence of 1, 2, 3, 4, 5 and 6 is worth 1,500 points.

For a combination to count, it must be obtained in a single throw.

  Example

First roll of the dice : Player receives 6 dice with values 1 4 1 1 3 6
Player keeps three dice of 1 for a score of 1000 points providing to the standard output one line with 1 1 1

Second roll of the dice : Player receives 3 dice with values 2 5 1
Player passes for a score of 150 points and scores a total of 1000 + 150 = 1150 points providing to the standard output one line with pass

  Note

Warning: one turn allows the dice to be re-rolled a maximum of 2 times.
Victory conditions
  • Be the first to reach 10,000 points.
Defeat conditions
  • Your opponent reaches 10,000 points before you do.
  • Your code does not respond in time or returns an unrecognized command.

  Game Input

Input

Line 1: an integer count, the number of rolled dice

Line 2: a string of space-separated integer values, the values of rolled dice

Output
A single line containing pass or a list of kept dice as a string of integers separated by spaces such as 1 1 5.