Modify Sequence
Practice
3.5 (131 votes)
Ad Hoc
Basic programming
Easy
Problem
83% Success 65432 Attempts 20 Points 3s Time Limit 256MB Memory 1024 KB Max Code

Suppose we have a sequence of non-negative integers, Namely a_1, a_2, ... ,a_n. At each time we can choose one term a_i with 0 < i < n and we subtract 1 from both a_i and a_i+1. We wonder whether we can get a sequence of all zeros after several operations.

Input

The first line of test case is a number N. (0 < N <= 10000) The next line is N non-negative integers, 0 <= a_i <= 109

Output

If it can be modified into all zeros with several operations output “YES” in a single line, otherwise output “NO” instead.

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
262 votes
Tags:
Data StructuresEasyHiringOne-dimensionalReady
Points:20
75 votes
Tags:
1-D ArrayArraysData StructuresEasy
Points:30
3 votes
Tags:
CombinatoricsEasyFibonacci numberMath