#include using namespace std; int main() { int N; cin >> N; vector A(N); for (int i = 0; i < N; i++){ cin >> A[i]; } vector B(N); for (int i = 0; i < N; i++){ cin >> B[i]; } vector C = {0}; bool ok = true; for (int i = 0; i < N - 1; i++){ if (A[i + 1] - A[i] > abs(B[i + 1] - B[i])){ if (ok){ C.push_back(0); ok = false; } C.back()++; } else { ok = true; } } C.back()++; long long ans = 0; for (int i : C){ ans += (long long) i * (i - 1) / 2; } cout << ans << '\n'; }