import java.util.Scanner; public class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] pro = new int[n]; int[] name = new int[n]; for(int i = 0; i < n; i++){ pro[i] = sc.nextInt(); } for(int i = 0; i < n; i++){ name[i] = sc.nextInt(); } int[] point = new int[100]; for(int i = 0; i < 100; i++){ point[i] = 100; } for(int i = 0; i < 100; i++){ for(int j = 0; j < n; j++){ if(name[j] == i){ point[i] = point[i] + pro[j]; } } } int ans = point[0]; for(int i = 1; i < 100; i++){ if(ans