Problem Description

Read n integers, find the earliest index i (1-based) where the prefix sum value has appeared before. If never repeats, output -1.

Input Format

First line n. Second line n integers.

Output Format

One integer index or -1.

Sample Test Case

Input:
6 1 2 -3 4 -4 0
Output:
3

Constraints

1

Solutions (0)

No solutions submitted yet. Be the first!

Discussion (0)

No comments yet. Start the discussion!

Prev Next