N = int(input())
H_li = list(map(int, input().split(' ')))

def check(H):
  H_max = max(H_li)
  max_indexs = ([i for i, x in enumerate(H_li) if x == H_max])

  if len(max_indexs) > 1:
    max_index = max(max_indexs)
    min_index = min(max_indexs)

    return min_index + len(max_indexs)

  else:
    return max_indexs[0] + 1


S = check(H_li)
 
print(S)


 