Codeforces Round 984 (Div. 3) |
---|
Finished |
Boris Notkin composes melodies. He represents them as a sequence of notes, where each note is encoded as an integer from $$$0$$$ to $$$127$$$ inclusive. The interval between two notes $$$a$$$ and $$$b$$$ is equal to $$$|a - b|$$$ semitones.
Boris considers a melody perfect if the interval between each two adjacent notes is either $$$5$$$ semitones or $$$7$$$ semitones.
After composing his latest melodies, he enthusiastically shows you his collection of works. Help Boris Notkin understand whether his melodies are perfect.
The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 1000$$$) — the number of melodies.
Each melody is described by two lines.
The first line contains an integer $$$n$$$ ($$$2 \leq n \leq 50$$$) — the number of notes in the melody.
The second line contains $$$n$$$ integers $$$a_{1}, a_{2}, \dots, a_{n}$$$ ($$$0 \leq a_{i} \leq 127$$$) — the notes of the melody.
For each melody, output "YES", if it is perfect; otherwise, output "NO".
You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.
82114 109217 10376 83 88838 45 38 80 85 92 99 106563 58 65 58 658117 124 48 53 48 43 54 49595 102 107 114 1211072 77 82 75 70 75 68 75 68 75
YES YES YES NO YES NO YES YES
Name |
---|