n = int(input()) a = list(map(int,input().split())) b = list(map(int,input().split())) cnt = 1 ans = 0 for i in range(n-1): if a[i] + max(b[i],b[i+1]) < a[i+1] + min(b[i],b[i+1]): cnt += 1 else: ans += cnt * (cnt-1) //2 cnt = 1 ans += cnt * (cnt-1) //2 print(ans)