FIICode 2024 Elevi | School Championship

This was the problem page during the contest. Access the current page here.
Time limit: 1s Memory limit: 256MB Input: Output:

The 1T academy wants to organize the school Legends of the League championship. Rekaf is in charge of making teams in his class, but he is too busy practicing his favourite character Zeb, so he asks you to help.

There are nn students in Rekaf's class, each having a power level aia_i. Because you are also pretty busy, you chose a simple method to form teams:

  1. Choose 33 integers ii, jj, and kk (1i<j<k<n1 \le i < j < k < n).
  2. Create 44 teams:
    • AA contains students 1,2,,i1, 2, \ldots, i.
    • BB contains students i+1,i+2,,ji + 1, i + 2, \ldots, j.
    • CC contains students j+1,j+2,,kj + 1, j + 2, \ldots, k.
    • DD contains students k+1,k+2,,nk + 1, k + 2, \ldots, n.

Let sum(X)\mathrm{sum}(X) be the sum of power levels of students in team XX.

Because you want the teams to be somewhat balanced, you will choose ii, jj, and kk such that sum(A)=sum(D)\mathrm{sum}(A) = \mathrm{sum}(D) and sum(B)=sum(C)\mathrm{sum}(B) = \mathrm{sum}(C).

Input

The first line contains a single integer nn (1n1061 \le n \le 10^6) — the length of the array aa.

The second line contains nn integers a1,a2,,ana_1, a_2, \ldots, a_n (1ai1091 \le a_i \le 10^9).

Output

Print ii, jj, and kk.

If there are multiple solutions, print the lexicographically smallest one. The triplet (a,b,c)(a, b, c) is smaller than (x,y,z)(x, y, z) if any of the following holds true:

  • a<xa < x;
  • a=xa = x and b<yb < y;
  • a=xa = x and b=yb = y and c<zc < z.

For example, (1,2,3)<(3,4,5)(1, 2, 3) < (3, 4, 5), (3,4,7)<(3,5,6)(3, 4, 7) < (3, 5, 6), and (1,2,3)<(1,2,4)(1, 2, 3) < (1, 2, 4).

If there are no solutions, print 1-1.

Example 1

stdin

8
1 1 2 1 2 4 1 2

stdout

2 5 7

Example 2

stdin

5
1 1 1 1 1

stdout

-1

Notes

In the first example, the teams are A=1,1A = \langle 1, 1 \rangle, B=2,1,2B = \langle 2, 1, 2 \rangle, C=4,1C = \langle 4, 1 \rangle, and D=2D = \langle 2 \rangle. Therefore, sum(A)=sum(D)=2\mathrm{sum}(A) = \mathrm{sum}(D) = 2 and sum(B)=sum(C)=5\mathrm{sum}(B) = \mathrm{sum}(C) = 5.

Log in or sign up to be able to send submissions!