import bisect
def countGreaterRight(arr):
n = len(arr)
res = [0] * n
os = []
for i in range(n - 1, -1, -1):
pos = bisect.bisect_right(os, arr[i])
res[i] = len(os) - pos # strictly greater
bisect.insort(os, arr[i])
return res
def countSmallerLeft(arr):
n = len(arr)
res = [0] * n
os = []
for i in range(n):
pos = bisect.bisect_left(os, arr[i] + 1)
res[i] = pos # strictly smaller
bisect.insort(os, arr[i])
return res
def main():
n = int(input())
v = list(map(int, input().split()))
assert all(x < n for x in v)
greaterRight = countGreaterRight(v)
smallerLeft = countSmallerLeft(v)
specialCount = 0
for i in range(n):
if greaterRight[i] >= v[i] or smallerLeft[i] >= v[i]:
specialCount += 1
print(specialCount)
if __name__ == "__main__":
main()