#include <bits/stdc++.h>
using namespace std;

const int inf = (1 << 30) - 1;

int main()
{
	int N;
	int A[15], W[15];
	int minv[2];

	cin >> N;

	for ( int i = 0; i < N; i++ ) cin >> A[i];
	for ( int i = 0; i < N; i++ ) cin >> W[i];
	
	minv[0] = minv[1] = inf;

	for ( int i = 0; i < N; i++ ) {
		minv[A[i]] = min(minv[A[i]], W[i]);
	}

	if ( minv[0] == inf || minv[1] == inf ) {
		cout << 0 << endl;
	} else {
		cout << minv[0] + minv[1] << endl;
	}

	return ( 0 );
}

