跳到主要内容
图灵 OJTURING / ONLINE JUDGE

#F0764. Array Division

    ID: 770 传统题 2000ms 256MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>二分数据结构模拟算法思想编程与模拟提高难度共享题库Codeforces英文题面题目来源题面语言

Array Division

题目描述

D. Array Division
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Vasya has an array a consisting of positive integer numbers. Vasya wants to divide this array into two non-empty consecutive parts (the prefix and the suffix) so that the sum of all elements in the first part equals to the sum of elements in the second part. It is not always possible, so Vasya will move some element before dividing the array (Vasya will erase some element and insert it into an arbitrary position).

Inserting an element in the same position he was erased from is also considered moving.

Can Vasya divide the array after choosing the right element to move and its new position?

Input

The first line contains single integer n (1≤n≤100000) − the size of the array.

The second line contains n integers a1,a2... an (1≤ai≤109) − the elements of the array.

Output

Print YES if Vasya can divide the array after moving one element. Otherwise print NO.

Examples
Input
3
1 3 2
Output
YES
Input
5
1 2 3 4 5
Output
NO
Input
5
2 2 3 4 5
Output
YES
Note

In the first example Vasya can move the second element to the end of the array.

In the second example no move can make the division possible.

In the third example Vasya can move the fourth element by one position to the left.


题目来源:fps-www.educg.net-codeforce-1-2833.xml.zip;FPS 共享题包,题包内第 186 题。保留原作者与原赛事署名。