#include <bits/stdc++.h>   using namespace std;   void solve() {     long long n, z = 0;     cin >> n;     long long a[n], b[n];     for (long long i = 0; i < n; i++) {       cin >> a[i];     }     for (long long i = 0; i < n; i++) {       cin >> b[i];     }     vector<long long> neg, pos;     for (long long i = 0; i < n; i++) {       if (a[i] == b[i]) z++;       if ((a[i] - b[i]) >= 0)         pos.push_back(a[i] - b[i]);       else         neg.push_back(b[i] - a[i]);     }     if (!pos.empty()) sort(pos.begin(), pos.end());     if (!neg.empty()) sort(neg.begin(), neg.end());     long long ans = 0, cnt = 0, j = (long long)neg.size() - 1,               k = (long long)pos.size() - 1;     ans += (k * (k + 1)) / 2;     ans -= (z * (z - 1)) / 2;     while (j >= 0 && !pos.empty()) {       if (k >= 0 && neg[j] < pos[k]) {         cnt++;         k--;       } else {         ans += cnt;         j--;       }     }     cout << ans << endl;     return;   }   int main() {     long long t;     t = 1;     while (t--) {       solve();     }     return 0;   }   