#K69797. Valid Numbering Sequence
Valid Numbering Sequence
Valid Numbering Sequence
You are given an integer \( n \) representing the number of rooms, and a sequence of \( n \) integers representing the numbering of the rooms. A numbering sequence is considered valid if the absolute difference between any two consecutive numbers is \(1\), i.e., \( |a_i - a_{i-1}| = 1 \) for every \( i = 2,3,\dots,n \). Otherwise, the sequence is invalid.
Your task is to determine whether the given sequence is valid. For example:
- For \( n = 5 \) and sequence [1, 2, 3, 4, 5], the answer is VALID.
- For \( n = 3 \) and sequence [1, 3, 2], the answer is INVALID.
inputFormat
The input is read from stdin and consists of two lines. The first line contains an integer \( n \), denoting the number of rooms. The second line contains \( n \) space-separated integers representing the numbering sequence.
outputFormat
Output a single line to stdout. Print "VALID" if the numbering sequence is valid, otherwise print "INVALID".
## sample5
1 2 3 4 5
VALID