#include <bits/stdc++.h>

using namespace std;

const int maxn = 2e5 + 50;

int n , cnt[maxn] , loc[maxn] , id[maxn] , wind[maxn] , r[maxn] , m;
vector < pair < int , int > > f;

struct Node{
	int l , r , rc;
	long long c[2];

	void upd( int s ){
		rc += s;
		if( s >= 2 ) c[0] = c[1] = 0;
		else if( s == 1 ) c[1] = c[0] , c[0] = 0;
	}
}tree[maxn << 2];

void push_up( int o ){
	for(int i = 0 ; i < 2; ++ i)
		tree[o].c[i] = tree[o << 1].c[i] + tree[o << 1 | 1].c[i];
}

void push_down( int o ){
	if( tree[o].rc ){
		tree[o << 1].upd( tree[o].rc );
		tree[o << 1 | 1].upd( tree[o].rc );
		tree[o].rc = 0;
	}
}

void build( int l , int r , int o ){
	tree[o].l = l , tree[o].r = r;
	if( l < r ){
		int mid = l + r >> 1;
		build( l , mid , o << 1 );
		build( mid + 1 , r , o << 1 | 1 );
		push_up( o );
	}else
		tree[o].c[0] = cnt[id[l]];
}

void ins( int ql , int qr , int o ){
	int l = tree[o].l , r = tree[o].r;
	if( ql <= l && r <= qr ) tree[o].upd( 1 );
	else{
		int mid = l + r >> 1;
		push_down( o );
		if( ql <= mid ) ins( ql , qr , o << 1 );
		if( qr > mid ) ins( ql , qr , o << 1 | 1 );
		push_up( o );
	}
}

pair < long long , long long > cha( int ql , int qr , int o ){
	int l = tree[o].l , r = tree[o].r;
	if( ql <= l && r <= qr ) return make_pair( tree[o].c[0] , tree[o].c[1] );
	else{
		int mid = l + r >> 1;
		push_down( o );
		pair < long long , long long > g ;
		if( ql <= mid ){
			pair < long long , long long > t = cha( ql , qr , o << 1 );
			g.first += t.first;
			g.second += t.second;
		}
		if( qr > mid ){
			pair < long long , long long > t = cha( ql , qr , o << 1 | 1 );
			g.first += t.first;
			g.second += t.second;
		}
		push_up( o );
		return g;
	}
}

int lower( int x ){
	int l = 1 , r = n;
	while( l < r ){
		int mid = l + r >> 1;
		if( loc[id[mid]] >= x ) r = mid;
		else l = mid + 1;
	}
	if( loc[id[l]] < x ) ++ l;
	return l;
}

int main( int argc , char * argv[] ){
	scanf( "%d" , & n );
	for(int i = 1 ; i <= n ; ++ i)
		scanf( "%d" , cnt + i );
	for(int i = 1 ; i <= n ; ++ i)
		scanf( "%d" , loc + i );
	for(int i = 1 ; i <= n ; ++ i)
		id[i] = i;
	sort( id + 1 , id + n + 1 , [ & ]( const int & x , const int & y ){
		return loc[x] < loc[y];
	});
	build( 1 , n , 1 );
	scanf( "%d" , & m );
	for(int i = 1 ; i <= m ; ++ i)
		scanf( "%d" , wind + i );
	for(int i = 1 ; i <= m ; ++ i)
		scanf( "%d" , r + i );
	for(int i = 1 ; i <= m ; ++ i){
		int L = wind[i] - r[i];
		int R = wind[i] + r[i];
		L = lower( L );
		R = lower( R + 1 ) - 1;
		if( L > R ) continue;
		f.push_back( { L , R } );
		ins( L , R , 1 );
	}
	long long ans = tree[1].c[0];
	for(auto it : f){
		pair < long long , long long > w = cha( it.first , it.second , 1 );
		ans = max( ans , tree[1].c[0] + w.second );
	}
	printf( "%lld\n" , ans );
	return 0;
}