# 1435 Mmm...... n=int(input()) integers=list(map(int,input().split())) result=0 for l in range(n-1): minNum0=integers[l] minNum1=2*1e5+1 maxNum=integers[l] r=l+1 while rmaxNum: maxNum=integers[r] if maxNum>minNum0+minNum1: break result+=1 r+=1 print(result)