#import sys # input = sys.stdin.readline def mp():return map(int,input().split()) def lmp():return list(map(int,input().split())) def mps(A):return [tuple(map(int, input().split())) for _ in range(A)] import math import bisect import heapq from copy import deepcopy as dc from itertools import accumulate from collections import Counter, defaultdict, deque def ceil(U,V):return (U+V-1)//V def modf1(N,MOD):return (N-1)%MOD+1 inf = int(1e20) mod = int(1e9+7) n = int(input()) p = lmp() pp = [0]*(n+1) for i in range(n): pp[p[i]] = i+1 ppc = list(accumulate(pp)) ans = 0 for i in range(n): ans = max(ans, ppc[i]-pp[i+1]) print(ans)