atcoder#ABC265D. [ABC265D] Iroha and Haiku (New ABC Edition)

[ABC265D] Iroha and Haiku (New ABC Edition)

Score : 400400 points

Problem Statement

There is a sequence A=(A0,,AN1)A=(A_0,\ldots,A_{N-1}) of length NN. Determine if there exists a tuple of integers (x,y,z,w)(x,y,z,w) that satisfies all of the following conditions:

  • 0x<y<z<wN0 \leq x < y < z < w \leq N
  • Ax+Ax+1++Ay1=PA_x + A_{x+1} + \ldots + A_{y-1} = P
  • Ay+Ay+1++Az1=QA_y + A_{y+1} + \ldots + A_{z-1} = Q
  • Az+Az+1++Aw1=RA_z + A_{z+1} + \ldots + A_{w-1} = R

Constraints

  • 3N2×1053 \leq N \leq 2\times 10^5
  • 1Ai1091 \leq A_i \leq 10^9
  • 1P,Q,R10151 \leq P,Q,R \leq 10^{15}
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN PP QQ RR

A0A_0 A1A_1 \ldots AN1A_{N-1}

Output

If there exists a tuple that satisfies the conditions, print Yes; otherwise, print No.

10 5 7 5
1 3 2 2 2 3 1 4 3 2
Yes

(x,y,z,w)=(1,3,6,8)(x,y,z,w)=(1,3,6,8) satisfies the conditions.

9 100 101 100
31 41 59 26 53 58 97 93 23
No
7 1 1 1
1 1 1 1 1 1 1
Yes