import sys input = sys.stdin.readline N = int(input()) A = list(map(int, input().split())) i = 0 ans = 0 while i