Mock CCC '22 Contest 2 J3 - Figure Skating Fun

View as PDF

Submit solution


Points: 5 (partial)
Time limit: 1.0s
Memory limit: 256M

Author:
Problem type

Andrew has just finished judging the figure skating event! There were N competitors, and the i^\text{th} one received a score of S_i.

Since Andrew likes symmetry, he wants to find the spot to split the scores such that the sum of the scores on the left equals the sum of the scores on the right. Splitting between competitor M and competitor M+1 is defined as spot M. Help Andrew find this spot!

Constraints

1 \le N \le 10^6

1 \le S_i \le 100

Subtask 1 [10/15]

1 \le N \le 10^4

Subtask 2 [5/15]

No additional constraints.

Input Specification

The first line contains one integer N, the number of competitors.

The second line contains N space-separated integers S_i, the score of the i^\text{th} competitor.

Output Specification

Output on a single line the spot M, or Andrew is sad. if it doesn't exist.

Sample Input 1

3
1 1 2

Sample Output 1

2

Explanation for Sample 1

Splitting between competitors 2 and 3, which is spot 2, yields the desired result: left of the spot sums to 1+1=2, while the right of the spot sums to 2.

Sample Input 2

3
1 1 1

Sample Output 2

Andrew is sad.

Comments

There are no comments at the moment.