#CCBCHBAHAI0000163. Chỉ số max cuối cùng (Last Maximum Index)

Chỉ số max cuối cùng (Last Maximum Index)

Last Maximum Index

Source: Phước Hưng OJ

Version: Phuoc Hung OJ Extended

Problem

Given an integer array aa of length nn, indexed from 00 to n−1n-1. Let M=max⁡0≤i<naiM=\max_{0\le i<n}a_i. Find

p=max⁡{i∣ai=M}.p=\max\{i\mid a_i=M\}.

Ties must be resolved by choosing the last occurrence.

Input

  • Line 1: integer nn.
  • Line 2: nn integers a0,…,an−1a_0,\ldots,a_{n-1}.

Output

Print the 0-based index pp.

Subtask

Subtask 1 (100 points): 1≤n≤1051\le n\le10^5; −109≤ai≤109-10^9\le a_i\le10^9.

Example

Input

7
3 9 4 9 2 9 1

Output

5

Explanation

The maximum 99 occurs at indices 1,3,51,3,5; the last is 55.