#C10119. Palindrome Sequence Checker
Palindrome Sequence Checker
Palindrome Sequence Checker
You are given a sequence of integers. Your task is to determine whether the sequence is a palindrome. A sequence \(a_1, a_2, \ldots, a_n\) is called a palindrome if it reads the same forward and backward, i.e., if \(a_i = a_{n-i+1}\) for all \(1 \leq i \leq n\). If the sequence is a palindrome, print YES
; otherwise, print NO
.
For example, the sequence [1, 2, 3, 2, 1] is a palindrome, while [1, 2, 3, 4, 5] is not.
inputFormat
The first line of input contains an integer \(n\) representing the number of elements in the sequence. The second line contains \(n\) space-separated integers.
Note: The input is provided via standard input (stdin).
outputFormat
Output a single line to standard output (stdout) with YES
if the sequence is a palindrome, and NO
otherwise.
5
1 2 3 2 1
YES