#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define per(i,a,b) for (int i = a; i >= b; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
const int MAXN = 110;
int a[MAXN], b[MAXN];
int main() {
ios_base::sync_with_stdio(0);cin.tie(nullptr);
int n; cin >> n;
rep(i,1,n) cin >> a[i];
rep(i,1,n) cin >> b[i];
vector<int>x,y;
int s = 0;
rep(i,1,n) {
rep(j,1,a[i]) x.pb(i);
rep(j,1,b[i]) y.pb(i);
s+=b[i];
}
while(1) {
bool ok = 1;
rep(j,0,(int)y.size()-2) {
if((x[j] == y[j] && y[j]<y[j+1]) || x[j] > y[j]) {
int tmp = y[j];
y.erase(y.begin() + j);
y.pb(tmp);
ok = 0;
}
}
if(ok)break;
/*rep(j,0,(int)y.size()-1) cout << x[j] << ' ';
cout << endl;
rep(j,0,(int)y.size()-1) cout << y[j] << ' ';
cout << endl;
cout << "BRUH: \n"; */
}
int ans = 0;
rep(i,0,(int)y.size()-1) {
if(x[i]<y[i]) ans++;
else if(x[i]>y[i]) ans--;
}
cout << ans << endl;
return 0;
}