#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int Mod=1e9+7;
const ll INF = 10000000000000;
const int N = 1e6+7;

    void solve() {
        int n;
        cin >> n;
        vector<pair<int,int>> a(n);
        for(int i=0;i<n;i++) cin >> a[i].first;
        for(int i=0;i<n;i++) cin >> a[i].second;
        vector<int> ch(n);
        for(int i=0;i<n;i++) ch[i]=a[i].first-a[i].second;
        sort(ch.begin(),ch.end());
        int l=0,r=n-1;
        int ans = 0;
        while(l<=r){
           if(ch[l]+ch[r]>0){
              ans+=r-l;
              r--;  
           }
           else l++;
        }
        cout << ans << '\n';
    }

int main(){ 
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
	
    /*int t;
    cin >> t;
    while (t--)*/ solve();
    
    return 0;
}
