#include <bits/stdc++.h>
#define int long long int
#define endl "\n"
#define loop(i,n) for(int i=1;i<=n;i++)
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fileread freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define pb push_back
#define mp make_pair
#define all(v) v.begin() , v.end()
#define itr iterator
#define fi first
#define se second
#define pii pair<int,int>
#define pci pair<char,int>
#define u_map unordered_map
#define u_set unordered_set
#define u_mmap unordered_multimap
#define u_mset unordered_multiset
# define pi 3.14159265358979323846
using namespace std;

/*
    s.push_back() is used to push_back a character whereas += is used to push_back a string
    str[i] acts as both string as well as character
    if you want to iterate a string without knowing the size of the string, use '\0' in for loop
    for(int i = 0; str[i] != '\0'; i++) 
    
--------------------------------------------------------------------------------------------------------
    vector<int> v; 
    v.assign(n,-2);
    
    -> way to assign size of vector and fill it the entire vector with num of choice
    
    If you want to insert a value at a particular position, use insert(vector iterator, value)
    
    vector<int> vec = { 10, 20, 30, 40 }; 
    vec.insert(vec.begin() + 2, 50);
    
    vec becomes : {10, 20, 50, 30, 40}
--------------------------------------------------------------------------------------------------------

    STRING FIND: returns the index of 1st occurence of char or string passed to a string str
    the optional second argument(0 by default) specifies the initial position from where the string 
    search is to begin
    
    string str="geeks are here!";
    int found =str.find('x');
	if(found!=string::npos) cout<<found;
	else cout<<"not found";
	
	string::npos has an int value of -1;

--------------------------------------------------------------------------------------------------------

    STRING GETLINE: before using getline for the 1st time, use : cin.ignore() once.

--------------------------------------------------------------------------------------------------------

    Convert single character to string : char c='a'; string str(1,c);

--------------------------------------------------------------------------------------------------------
	
    For LCM:
    int LCM(int a, int b)
    {
        return (b*a)/GCD(a,b);
    }
    
--------------------------------------------------------------------------------------------------------
    
    In math problems, if you want to find maximum value in an array of integers,
    initialize "maxx" to -INT_MAX & not to 0 (incase all intergers are negative 0 is not maximum)

--------------------------------------------------------------------------------------------------------

    character arithmetic : 
            'a'-'a' = 0
            'b'-'a' = 1
    USE : when you want to store count of characters in specific position in a vector or array,
    EX : store 'a' at 0, store 'b' at 1...
    
    given : string str= "welcome to codeforces";
            int arr[26];
            for(int i=0;i<26;i++){
                arr[str[i]-'a']++;
            }
    NO NEED TO CONVERT CHAR TO INT

--------------------------------------------------------------------------------------------------------

    In map, you can modify the value but not the key
    However, in a set of pairs, you can neither modify the first element nor the second one.
    
    In a set of pairs, the find will require the arguments as a pair of int
    
    In a map, you cannot have two entries with the same "key"
    For this purpose multimap can be used. Obviously, m[v[i]]=i does not work for multimap as v[i] is not distinct
    Use insert(make_pair(v[i],i));
    
--------------------------------------------------------------------------------------------------------

    Interactive problems : Use IOS; During cout, put "\n" at the end of cout;
                            After "\n", use cout<<flush; After that accept input;

--------------------------------------------------------------------------------------------------------

*/


/*
int n,m;
vector< vector <int> > adj;
vector<bool> vis;

void addedge(int u, int v){
    adj[u].pb(v);
    adj[v].pb(u);
}

void bfs(int src){
    queue<int> q;
    q.push(src);
    vis[src]=true;
    while(!q.empty()){
        int curr=q.front();
        q.pop();
        for(int i=0;i<adj[curr].size();i++){
            int node=adj[curr][i];
            if(!vis[node]){
                q.push(node);
                vis[node]=true;
            }
        }
    }
}

void printgraph(){
    for(int i=0;i<n;i++){
        cout<<i<<" -> ";
        for(int j=0;j<adj[i].size();j++) cout<<adj[i][j]<<" ";
        cout<<endl;
    }
}
*/


signed main() {
	/*
	----------
	----------
	----------
	----------
	----------
	----------
	----------
	----------
	----------
	----------
	----------
	----------
	----------
	----------
    */
    
    int n;
    cin>>n;
    int val[n+1],cost[n+1];
    loop(i,n) cin>>val[i];
    loop(i,n) cin>>cost[i];
    int num=pow(2,n);
    num--;
    int maxx=INT_MIN;
    for(int i=1;i<=num;i++){
        int j=1,cnt=0,pos=1;;
        while(j<=i){
            int tell=i&j;
         //   cout<<i<<" "<<j<<" "<< tell <<"\n";
            if(tell>0){
                //cout<<"*";
                cnt+=val[pos]-cost[pos];
            }
            pos++;
//            cout<<i<<" "<<j<<"\n";
            j<<=1;
        }
       // cout<<cnt<<"\n\n";
        if(cnt>maxx) maxx=cnt;
    }
    
    if(maxx>0)cout<<maxx;
    else cout<<0;
    
    
}

Measured memory_bytes: 512