#include using namespace std; #define int long long signed main(){ int N; cin>>N; vector A(N),B(N); for(int i=0;i>A[i]; for(int i=0;i>B[i]; int streak = 0; int ans = 0; for(int i=1;i A[i-1]+max(B[i],B[i-1])) streak++; else{ ans += streak*(streak+1)/2; streak=0; } } ans += streak*(streak+1)/2; cout<