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

#TP0000037. Alice, Bob và những thanh sô-cô-la (Alice, Bob and Chocolate)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Alice, Bob và những thanh sô-cô-la (Alice, Bob and Chocolate)

Alice, Bob and Chocolate

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

There are nn chocolate bars arranged from left to right. Alice eats from the left and Bob from the right. Both start simultaneously, eat at the same speed, never pause, and finish each bar before taking another. Bar ii takes tit_i seconds to eat. Whenever a player finishes, they immediately take the next available bar at their end. If both simultaneously reach the final remaining bar, Alice gets it. Determine how many bars each player eats.

Input

  • The first line contains nn, the number of bars.
  • The second line contains exactly nn integers t1,…,tnt_1,\ldots,t_n in left-to-right order.

Output

Print two integers aa and bb: the numbers of bars eaten by Alice and Bob, respectively.

Subtasks

  • Subtask 1 (20 points): 1≤n≤81\le n\le8; 1≤ti≤10001\le t_i\le1000 for all 1≤i≤n1\le i\le n.
  • Subtask 2 (30 points): 1≤n≤20001\le n\le2000; 1≤ti≤10001\le t_i\le1000 for all 1≤i≤n1\le i\le n.
  • Subtask 3 (50 points): 1≤n≤1000001\le n\le100000; 1≤ti≤10001\le t_i\le1000 for all 1≤i≤n1\le i\le n.

Examples

Input

5
2 9 8 2 7

Output

2 3

Explanation

Alice finishes bar 11 at time 22 and starts bar 22, which finishes at time 1111. Bob finishes bar 55 at time 77, bar 44 at time 99, then takes bar 33. The counts are therefore 22 for Alice and 33 for Bob.