Loading...
Mirror Check
Time: 1 s
Memory: 256 MB
Rafi and Rahat are playing a fun number game.
Rafi challenges Rahat to create a perfectly mirrored sequence — a sequence that looks exactly the same when split into two equal parts and the second half is reversed.
Given an array A of even length n, determine whether the first half of the array is exactly equal to the reversed second half.
In other words:
  • First half: A[0] to A[n/2 - 1]
  • Second half: A[n/2] to A[n - 1]
Check if A[0] == A[n-1], A[1] == A[n-2], ..., A[n/2 - 1] == A[n/2].
Input
The first line contains a single even integer n — the length of the array.
The second line contains n space-separated integers A[0], A[1], ..., A[n-1].
Constraint
2 ≤ n ≤ 10^5
n is even
1 ≤ A[i] ≤ 100
Output
Print "YES" if the array is a perfect mirror.
Otherwise, print "NO".
Examples
Input
Output
6
1 2 3 3 2 1
YES
Input
Output
2
10 9
NO
Notes
  • The array length n is guaranteed to be even.
  • The elements of the array are positive integers.
  • Your task is only to check the condition and print the answer accordingly.
Problem Info
Problem ID 520
Time Limit 1000 ms
Memory Limit 262144 KB
Moderators saklan
Statistics
Submit
You need to Login or Registration for submit your solution