#include #include using namespace std; int a[200009], b[200009]; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= n; i++) cin >> b[i]; int c = 0; long long ans = 0; for (int i = 1; i <= n; i++) { c++; if (i == n || a[i] + b[i] >= a[i + 1] + b[i + 1] || a[i] - b[i] >= a[i + 1] - b[i + 1]) { ans += 1LL * c * (c - 1) / 2LL; c = 0; } } cout << ans << '\n'; return 0; }