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

#CCBCHBON0000001. Dừng tại số âm đầu tiên (Stop at the First Negative Number)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Dừng tại số âm đầu tiên (Stop at the First Negative Number)

Stop at the First Negative Number

Source: Phước Hưng OJ

Version: Phuoc Hung OJ Extended

Problem Statement

Given nn integers a1,…,ana_1,\ldots,a_n, find the first 1-based position whose value is negative. Print -1 if there is none, including n=0n=0. This exercise practices exiting a loop with break.

Input

The first value is nn, followed by exactly nn integers separated by whitespace. Every ai∈[−106,106]a_i\in[-10^6,10^6].

Output

Print the first negative position, or -1.

Subtasks

  • Subtask 1 (20%): 0≤n≤80\le n\le 8; −106≤ai≤106-10^6\le a_i\le10^6.

  • Subtask 2 (30%): 0≤n≤10000\le n\le 1000; −106≤ai≤106-10^6\le a_i\le10^6.

  • Subtask 3 (50%): 0≤n≤1000000\le n\le 100000; −106≤ai≤106-10^6\le a_i\le10^6.

Examples

Example 1

Input:

5
2 0 -4 -7 9

Output:

3

Explanation:

Scan left to right; the first negative value determines the reported position.

Example 2

Input:

0

Output:

-1

Explanation:

Scan left to right; the first negative value determines the reported position.