PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#BS0000131. Ba đoạn liên tiếp có tổng định trước (Iroha and Haiku (New ABC Edition))

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

2 lộ trình

Ba đoạn liên tiếp có tổng định trước (Iroha and Haiku (New ABC Edition))

Iroha and Haiku (New ABC Edition)

Source: AtCoder

Version: Phuoc Hung OJ Extended

Problem Statement

Given positive integers A0,…,An−1A_0,\ldots,A_{n-1} and targets P,Q,RP,Q,R, determine whether there exist four integers 0≤x<y<z<w≤n0\le x<y<z<w\le n such that three nonempty consecutive segments Ax,…,Ay−1A_x,\ldots,A_{y-1}; Ay,…,Az−1A_y,\ldots,A_{z-1}; Az,…,Aw−1A_z,\ldots,A_{w-1} have sums exactly P,Q,RP,Q,R respectively. The chosen segments need not cover the full array.

Input

The first line contains n,P,Q,Rn,P,Q,R. The next line contains nn integers A0,…,An−1A_0,\ldots,A_{n-1}.

Output

Print Yes if suitable indices exist; otherwise print No.

Subtasks

  • Subtask 1 (20 points): 3≤n≤303\le n\le 30; 1≤Ai≤109; 1≤P,Q,R≤10151\le A_i\le10^9;\ 1\le P,Q,R\le10^{15}, 0≤i<n0\le i<n.
  • Subtask 2 (30 points): 3≤n≤25003\le n\le 2500; 1≤Ai≤109; 1≤P,Q,R≤10151\le A_i\le10^9;\ 1\le P,Q,R\le10^{15}, 0≤i<n0\le i<n.
  • Subtask 3 (50 points): 3≤n≤2000003\le n\le 200000; 1≤Ai≤109; 1≤P,Q,R≤10151\le A_i\le10^9;\ 1\le P,Q,R\le10^{15}, 0≤i<n0\le i<n.

Examples

Input

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

Output

Yes

Explanation

Choose zero-based (x,y,z,w)=(1,3,6,8)(x,y,z,w)=(1,3,6,8). The three consecutive sums are A1+A2=3+2=5=PA_1+A_2=3+2=5=P, A3+A4+A5=2+2+3=7=QA_3+A_4+A_5=2+2+3=7=Q, and A6+A7=1+4=5=RA_6+A_7=1+4=5=R. Since 1<3<6<81<3<6<8, print Yes.