Problem: Grigory has magic stones, conveniently numbered from to . The charge of the -th stone is equal to .
Sometimes Grigory gets bored and selects some inner stone (that is, some stone with index , where ), and after that synchronizes it with neighboring stones. After that, the chosen stone loses its own charge, but acquires the charges from neighboring stones. In other words, its charge changes to .
Andrew, Grigory's friend, also has stones with charges . Grigory is curious, whether there exists a sequence of zero or more synchronization operations, which transforms charges of Grigory's stones into charges of corresponding Andrew's stones, that is, changes into for all ?
Input Format: The first line contains one integer () — the number of magic stones.
The second line contains integers () — the charges of Grigory's stones.
The second line contains integers () — the charges of Andrew's stones.
Output Format: If there exists a (possibly empty) sequence of synchronization operations, which changes all charges to the required ones, print "Yes".
Otherwise, print "No".
Note: In the first example, we can perform the following synchronizations (-indexed):
- First, synchronize the third stone .
- Then synchronize the second stone: .
In the second example, any operation with the second stone will not change its charge.