#include #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]; } atcoder::dsu uf(N); for (int i = 0; i < N - 1; i++){ if (A[i + 1] - A[i] > abs(B[i + 1] - B[i])){ uf.merge(i, i + 1); } } long long ans = 0; for (auto s : uf.groups()){ int m = s.size(); ans += (long long) m * (m - 1) / 2; } cout << ans << '\n'; }