import numpy as np N = int(input()) input_np = np.array(input().split()).astype(np.int32) log = [] for i in range(N - 1): all_max = np.max(input_np[i:N]) all_min = np.min(input_np[i:N]) tmp_max = input_np[i] if input_np[i] > input_np[i+1] else input_np[i+1] tmp_min = input_np[i] if input_np[i] <= input_np[i+1] else input_np[i+1] tmp_log = [] if [tmp_min, tmp_max] not in log: log.append([tmp_min, tmp_max]) for k in range(i+2, N): if tmp_max < input_np[k]: tmp_max = input_np[k] if [tmp_min, tmp_max] in log: break log.append([tmp_min, tmp_max]) elif tmp_min > input_np[k]: tmp_min = input_np[k] if [tmp_min, tmp_max] in log: break log.append([tmp_min, tmp_max]) if (all_max == tmp_max) and (all_min == tmp_min): break print(len(log))