404046: GYM101401 J Jackaroo

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

J. Jackarootime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

You must have heard of the board game Jackaroo. The lonely geeks of the ACM community at PSUT decided to launch a solo version of that game. Basically, the aim of the game is to try and get all your N marbles to end up in their N home spots (i.e. the green holes at the center of the board as in the picture below).

The lonely geeks decided that this game must be played with an unlimited number of one single lonely card, the 7 card. Using a 7 card, you can move any marble 7 steps, or split the seven moves between two marbles (i.e. the sum of their moves must be 7). The marbles can only move clockwise starting from the outside (i.e. they can't go backwards), no two marbles can be in the same spot after playing any of the cards, and marbles can jump over each other as long as they are not in any of the home spots. The first hole outside the home is numbered 1 and the numbering increases counterclockwise. Given the number of marbles N, and their positions on the board, determine if its possible to get all of your marbles in the homes.

Input

The first line of input contains a single integer N (1 ≤ N ≤ 50), the number of marbles.

The second line of input contains N distinct space-separated integers, each between 1 and 500 and represent the position of one of the marbles.

Output

Print "yes" if it is possible to get all of the marbles in the homes, otherwise print "no".

ExamplesInput
3
1 2 8
Output
yes
Input
2
1 4
Output
no
Input
5
1 2 6 7 9
Output
yes

加入题单

上一题 下一题 算法标签: