
import java.util.*;
import java.io.*;

public class Compute {

    static int N, M, K;
    static String s;
    static StringTokenizer st;
    static pair[] d;

    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);

        N = Integer.parseInt(br.readLine());
        
        d = new pair[N];

        st = new StringTokenizer(br.readLine());
        for (int i = 0; i < N; i++) {
            d[i] = new pair(0, 0);
            d[i].a = Integer.parseInt(st.nextToken());
        }
        st = new StringTokenizer(br.readLine());
        for (int i = 0; i < N; i++) {
            d[i].b = Integer.parseInt(st.nextToken());
        }

        double[][][] dp = new double[105][105][105];
        double val[] = new double[N + 1];

        long bot = 0;
        long top = new Long("1000000000000");
        long mid = 0;

        Arrays.sort(d);

        while (bot <= top) {
            mid = (bot + top) / 2;

            //System.out.println(mid + " " + top + " " + bot + " " + Math.abs(min) + " " + (Math.abs(min) < 0.001));
            //System.out.println(min < 0);
            boolean check = check(mid);
            if (check) {
                top = mid - 1;
            } else {
                bot = mid + 1;
            }
        }

        long ans = (bot + 9) / 10;

        out.println(ans);

        out.close();
    }

    static class pair implements Comparable<pair> {

        int a, b;

        public pair(int _a, int _b) {
            this.a = _a;
            this.b = _b;
        }

        @Override
        public int compareTo(pair t) {
            return (a == t.a) ? b - t.b : t.a - a;
        }
    }

    static boolean check(long mid) {
        //System.out.println(mid);
        double[][][] dp = new double[105][105][105];
        double val[] = new double[N + 1];
        
        for (int i = 0; i < N; i++) {
            val[i] = d[i].a - mid / 10000.0 * d[i].b;
        }

        //System.out.println("");
        //System.out.println(mid + " " + Arrays.toString(val));
        for (int i = 0; i <= N; i++) {
            for (int j = 0; j <= N; j++) {
                for (int k = 0; k <= N; k++) {
                    dp[i][j][k] = 1 << 30;
                }
            }
        }

        dp[0][0][1] = val[0];

        for (int i = 0; i < N - 1; i++) {
            for (int j = 0; j <= N; j++) {
                for (int k = 0; k <= N; k++) {
                    if (d[i].a == d[i + 1].a) {
                        if (j > 0) {
                            dp[i + 1][j - 1][k] = Math.min(dp[i + 1][j - 1][k], dp[i][j][k]);
                        }
                        dp[i + 1][j][k + 1] = Math.min(dp[i + 1][j][k + 1], dp[i][j][k] + val[i + 1]);
                    } else {
                        if (j + k > 0) {
                            dp[i + 1][j + k - 1][0] = Math.min(dp[i + 1][j + k - 1][0], dp[i][j][k]);
                        }
                        dp[i + 1][j + k][1] = Math.min(dp[i + 1][j + k][1], dp[i][j][k] + val[i + 1]);
                    }

                }
            }
        }

        double min = 1;
        for (int i = 0; i <= N; i++) {
            for (int j = 0; j <= N; j++) {
                //System.out.print(dp[N-1][i][j] + " ");
                min = Math.min(dp[N - 1][i][j], min);
            }
            //System.out.println("");
        }
        
        //System.out.println(min);
        return min < 0;
    }
}
