Kalila and Dimna are two jackals living in a huge jungle. One day they decided to join a logging factory in order to make money. 

The manager of logging factory wants them to go to the jungle and cut n trees with heights a1, a2, ..., an. They bought a chain saw from a shop. Each time they use the chain saw on the tree number i, they can decrease the height of this tree by one unit. Each time that Kalila and Dimna use the chain saw, they need to recharge it. Cost of charging depends on the id of the trees which have been cut completely (a tree is cut completely if its height equal to 0). If the maximum id of a tree which has been cut completely is i (the tree that have height ai in the beginning), then the cost of charging the chain saw would be bi. If no tree is cut completely, Kalila and Dimna cannot charge the chain saw. The chainsaw is charged in the beginning. We know that for each i < j, ai < aj and bi > bj and also bn = 0 and a1 = 1. Kalila and Dimna want to cut all the trees completely, with minimum cost. 

They want you to help them! Will you?

Input

The first line of input contains an integer n (1 ≤ n ≤ 105). The second line of input contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109). The third line of input contains n integers b1, b2, ..., bn (0 ≤ bi ≤ 109).

It's guaranteed that a1 = 1, bn = 0, a1 < a2 < ... < an and b1 > b2 > ... > bn.

Output

The only line of output must contain the minimum cost of cutting all the trees completely.

Please, do not write the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.

Examples

Input

5
1 2 3 4 5
5 4 3 2 0


Output

25


Input

6
1 2 3 10 20 30
6 5 4 3 2 0


Output

138
import java.util.List;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Reader;
import java.util.Collections;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputStreamReader in = new InputStreamReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}
}

class Task {
    public void solve(int testNumber, InputStreamReader inSt, PrintWriter out) {
        InputReader in = new InputReader(inSt);

        int n = in.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }

        for (int i = 0; i < n; i++) {
            b[i] = in.nextInt();
        }

        ConvexHull convexHull = new ConvexHull(0, 0, b[0]);
        for (int i = 1; i < n - 1; i++) {
            long val = convexHull.getMinimum(a[i]);
            convexHull.addLine(val, b[i]);
        }

        out.println(convexHull.getMinimum(a[n - 1]));
    }

    public class ConvexHull {

        private List<Line> lines;


        public ConvexHull(int point, long c, long b) {
            this.lines = new ArrayList<Line>();
            Line initialLine = new Line(point, c, b);
            lines.add(initialLine);
        }

        void addLine(long c, long b) {
            while (!this.lines.isEmpty()) {
                Line lastLine = this.lines.get(this.lines.size() - 1);

                int intersectionPoint = getIntersectionPoint(c, b, lastLine.c, lastLine.b);
                if (intersectionPoint <= lastLine.point) {
                    this.lines.remove(this.lines.size() - 1);
                } else {
                    this.lines.add(new Line(intersectionPoint, c, b));
                    break;
                }
            }
        }

        long getMinimum(int point) {
            int lineIndex = getLineIndex(point);

            Line retLine = this.lines.get(lineIndex);
            return retLine.c + retLine.b * point;
        }

        private int getIntersectionPoint(long c1, long b1, long c2, long b2) {
            long upper = c1 - c2;
            long lower = b2 - b1;
            long x = (upper) / lower;
            if (upper % lower != 0) {
                x++;
            }
            x = Math.min(x, Integer.MAX_VALUE);
            return (int) x;
        }

        private int getLineIndex(int point) {
            Line searchLine = new Line(point, 0, 0);

            int lineIndex = Collections.binarySearch(this.lines, searchLine);
            if (lineIndex == -1) {
                lineIndex = 0;
            } else if (lineIndex < 0) {
                lineIndex = -lineIndex - 2;
            }
            return lineIndex;
        }

        class Line implements Comparable<Line> {
            int point;

            long c;
            long b;

            Line(int point, long c, long b) {
                this.point = point;
                this.c = c;
                this.b = b;
            }

            @Override
            public int compareTo(Line o) {
                return (this.point - o.point);
            }
        }
    }


    class InputReader {
        public BufferedReader reader;
        private String[] currentArray;
        int curPointer;

        public InputReader(InputStreamReader inputStreamReader) {
            reader = new BufferedReader(inputStreamReader);
        }

        public String next() {
            try {
                currentArray = null;
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        public void nextChars(char[] t) {
            try {
                currentArray = null;
                reader.read(t);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        public char nextChar() {
            try {
                currentArray = null;
                return (char) reader.read();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        public int nextInt() {
            if ((currentArray == null) || (curPointer >= currentArray.length)) {
                try {
                    currentArray = reader.readLine().split(" ");
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
                curPointer = 0;
            }
            return Integer.parseInt(currentArray[curPointer++]);
        }

        public long nextLong() {
            if ((currentArray == null) || (curPointer >= currentArray.length)) {
                try {
                    currentArray = reader.readLine().split(" ");
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
                curPointer = 0;
            }
            return Long.parseLong(currentArray[curPointer++]);
        }

    }
}

