import java.util.*;

public class Gloves {
    public int findMinimum(int n, int[] left, int[] right) {
        int leftsum=0;
        int rightsum=0;
        int sum=0;
        int leftmin=Integer.MAX_VALUE;
        int rightmin=Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            if(left[i]*right[i]==0){
                sum+=left[i]+right[i];
            }else{
                leftsum+=left[i];
                rightsum+=right[i];
                leftmin=Math.min(leftmin,left[i]);
                rightmin=Math.min(rightmin,right[i]);
            }
        }
        return Math.min(leftsum-leftmin+1,rightsum-rightmin+1)+1+sum;
    }
}