import java.util.Arrays;
import java.util.Scanner;

public class Main {
	MyScanner sc = new MyScanner();
	Scanner sc2 = new Scanner(System.in);
	long start = System.currentTimeMillis();
	long fin = System.currentTimeMillis();
	final int MOD = 1000000007;
	int[] dx = { 1, 0, 0, -1 };
	int[] dy = { 0, 1, -1, 0 };

	void run() {
		int n = sc.nextInt();
		String[] s = sc.next().split(":");
		int H = Integer.valueOf(s[0]);
		int M = Integer.valueOf(s[1]);
		if (n == 12) {
			if (H > 12) H = H % 10 == 0 ? 10 : H % 10;
			else if(H == 0) H = 1;
			if (M > 59) M %= 10;
		} else {
			if (H >= 24) H %= 10;
			if (M > 59) M %= 10;
		}
		s[0] = H < 10 ? "0" + H : H + "";
		s[1] = M < 10 ? "0" + M : M + "";
		System.out.println(s[0] +":" +s[1]);
	}

	public static void main(String[] args) {
		new Main().run();
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	void debug2(int[][] array) {
		for (int i = 0; i < array.length; i++) {
			for (int j = 0; j < array[i].length; j++) {
				System.out.print(array[i][j]);
			}
			System.out.println();
		}
	}

	boolean inner(int h, int w, int limH, int limW) {
		return 0 <= h && h < limH && 0 <= w && w < limW;
	}

	void swap(int[] x, int a, int b) {
		int tmp = x[a];
		x[a] = x[b];
		x[b] = tmp;
	}

	// find minimum i (k <= a[i])
	int lower_bound(int a[], int k) {
		int l = -1;
		int r = a.length;
		while (r - l > 1) {
			int mid = (l + r) / 2;
			if (k <= a[mid])
				r = mid;
			else
				l = mid;
		}
		// r = l + 1
		return r;
	}

	// find minimum i (k < a[i])
	int upper_bound(int a[], int k) {
		int l = -1;
		int r = a.length;
		while (r - l > 1) {
			int mid = (l + r) / 2;
			if (k < a[mid])
				r = mid;
			else
				l = mid;
		}
		// r = l + 1
		return r;
	}

	long gcd(long a, long b) {
		return a % b == 0 ? b : gcd(b, a % b);
	}

	long lcm(long a, long b) {
		return a * b / gcd(a, b);
	}

	boolean palindrome(String s) {
		for (int i = 0; i < s.length() / 2; i++) {
			if (s.charAt(i) != s.charAt(s.length() - 1 - i)) {
				return false;
			}
		}
		return true;
	}

	class MyScanner {
		int nextInt() {
			try {
				int c = System.in.read();
				while (c != '-' && (c < '0' || '9' < c))
					c = System.in.read();
				if (c == '-')
					return -nextInt();
				int res = 0;
				do {
					res *= 10;
					res += c - '0';
					c = System.in.read();
				} while ('0' <= c && c <= '9');
				return res;
			} catch (Exception e) {
				return -1;
			}
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		String next() {
			try {
				StringBuilder res = new StringBuilder("");
				int c = System.in.read();
				while (Character.isWhitespace(c))
					c = System.in.read();
				do {
					res.append((char) c);
				} while (!Character.isWhitespace(c = System.in.read()));
				return res.toString();
			} catch (Exception e) {
				return null;
			}
		}

		int[] nextIntArray(int n) {
			int[] in = new int[n];
			for (int i = 0; i < n; i++) {
				in[i] = nextInt();
			}
			return in;
		}

		int[][] nextInt2dArray(int n, int m) {
			int[][] in = new int[n][m];
			for (int i = 0; i < n; i++) {
				in[i] = nextIntArray(m);
			}
			return in;
		}

		double[] nextDoubleArray(int n) {
			double[] in = new double[n];
			for (int i = 0; i < n; i++) {
				in[i] = nextDouble();
			}
			return in;
		}

		long[] nextLongArray(int n) {
			long[] in = new long[n];
			for (int i = 0; i < n; i++) {
				in[i] = nextLong();
			}
			return in;
		}

		char[][] nextCharField(int n, int m) {
			char[][] in = new char[n][m];
			for (int i = 0; i < n; i++) {
				String s = sc.next();
				for (int j = 0; j < m; j++) {
					in[i][j] = s.charAt(j);
				}
			}
			return in;
		}
	}
}


import java.util.Arrays;
import java.util.Scanner;

public class Main {
	MyScanner sc = new MyScanner();
	Scanner sc2 = new Scanner(System.in);
	long start = System.currentTimeMillis();
	long fin = System.currentTimeMillis();
	final int MOD = 1000000007;
	int[] dx = { 1, 0, 0, -1 };
	int[] dy = { 0, 1, -1, 0 };

	void run() {
		int n = sc.nextInt();
		String[] s = sc.next().split(":");
		int H = Integer.valueOf(s[0]);
		int M = Integer.valueOf(s[1]);
		if (n == 12) {
			if (H > 12) {
				H %= 10;
			} else if(H == 0){
				H = 1;
			}
			if (M > 59) {
				M %= 10;
			}
		} else {
			if (H >= 24) {
				H %= 10;
			}
			if (M > 59) {
				M %= 10;
			}
		}
		s[0] = H < 10 ? "0" + H : H + "";
		s[1] = M < 10 ? "0" + M : M + "";
		System.out.println(s[0] +":" +s[1]);
	}

	public static void main(String[] args) {
		new Main().run();
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	void debug2(int[][] array) {
		for (int i = 0; i < array.length; i++) {
			for (int j = 0; j < array[i].length; j++) {
				System.out.print(array[i][j]);
			}
			System.out.println();
		}
	}

	boolean inner(int h, int w, int limH, int limW) {
		return 0 <= h && h < limH && 0 <= w && w < limW;
	}

	void swap(int[] x, int a, int b) {
		int tmp = x[a];
		x[a] = x[b];
		x[b] = tmp;
	}

	// find minimum i (k <= a[i])
	int lower_bound(int a[], int k) {
		int l = -1;
		int r = a.length;
		while (r - l > 1) {
			int mid = (l + r) / 2;
			if (k <= a[mid])
				r = mid;
			else
				l = mid;
		}
		// r = l + 1
		return r;
	}

	// find minimum i (k < a[i])
	int upper_bound(int a[], int k) {
		int l = -1;
		int r = a.length;
		while (r - l > 1) {
			int mid = (l + r) / 2;
			if (k < a[mid])
				r = mid;
			else
				l = mid;
		}
		// r = l + 1
		return r;
	}

	long gcd(long a, long b) {
		return a % b == 0 ? b : gcd(b, a % b);
	}

	long lcm(long a, long b) {
		return a * b / gcd(a, b);
	}

	boolean palindrome(String s) {
		for (int i = 0; i < s.length() / 2; i++) {
			if (s.charAt(i) != s.charAt(s.length() - 1 - i)) {
				return false;
			}
		}
		return true;
	}

	class MyScanner {
		int nextInt() {
			try {
				int c = System.in.read();
				while (c != '-' && (c < '0' || '9' < c))
					c = System.in.read();
				if (c == '-')
					return -nextInt();
				int res = 0;
				do {
					res *= 10;
					res += c - '0';
					c = System.in.read();
				} while ('0' <= c && c <= '9');
				return res;
			} catch (Exception e) {
				return -1;
			}
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		String next() {
			try {
				StringBuilder res = new StringBuilder("");
				int c = System.in.read();
				while (Character.isWhitespace(c))
					c = System.in.read();
				do {
					res.append((char) c);
				} while (!Character.isWhitespace(c = System.in.read()));
				return res.toString();
			} catch (Exception e) {
				return null;
			}
		}

		int[] nextIntArray(int n) {
			int[] in = new int[n];
			for (int i = 0; i < n; i++) {
				in[i] = nextInt();
			}
			return in;
		}

		int[][] nextInt2dArray(int n, int m) {
			int[][] in = new int[n][m];
			for (int i = 0; i < n; i++) {
				in[i] = nextIntArray(m);
			}
			return in;
		}

		double[] nextDoubleArray(int n) {
			double[] in = new double[n];
			for (int i = 0; i < n; i++) {
				in[i] = nextDouble();
			}
			return in;
		}

		long[] nextLongArray(int n) {
			long[] in = new long[n];
			for (int i = 0; i < n; i++) {
				in[i] = nextLong();
			}
			return in;
		}

		char[][] nextCharField(int n, int m) {
			char[][] in = new char[n][m];
			for (int i = 0; i < n; i++) {
				String s = sc.next();
				for (int j = 0; j < m; j++) {
					in[i][j] = s.charAt(j);
				}
			}
			return in;
		}
	}
}


import java.util.Arrays;
import java.util.Scanner;

public class Main {
	MyScanner sc = new MyScanner();
	Scanner sc2 = new Scanner(System.in);
	long start = System.currentTimeMillis();
	long fin = System.currentTimeMillis();
	final int MOD = 1000000007;
	int[] dx = { 1, 0, 0, -1 };
	int[] dy = { 0, 1, -1, 0 };

	void run() {
		int n = sc.nextInt();
		String[] s = sc.next().split(":");
		int H = Integer.valueOf(s[0]);
		int M = Integer.valueOf(s[1]);
		if (n == 12) {
			if (H > 12) H %= 10;
			if(H == 0) H = 1;
			if (M > 59) M %= 10;
		} else {
			if (H >= 24) H %= 10;
			if (M > 59) M %= 10;
		}
		s[0] = H < 10 ? "0" + H : H + "";
		s[1] = M < 10 ? "0" + M : M + "";
		System.out.println(s[0] +":" +s[1]);
	}

	public static void main(String[] args) {
		new Main().run();
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	void debug2(int[][] array) {
		for (int i = 0; i < array.length; i++) {
			for (int j = 0; j < array[i].length; j++) {
				System.out.print(array[i][j]);
			}
			System.out.println();
		}
	}

	boolean inner(int h, int w, int limH, int limW) {
		return 0 <= h && h < limH && 0 <= w && w < limW;
	}

	void swap(int[] x, int a, int b) {
		int tmp = x[a];
		x[a] = x[b];
		x[b] = tmp;
	}

	// find minimum i (k <= a[i])
	int lower_bound(int a[], int k) {
		int l = -1;
		int r = a.length;
		while (r - l > 1) {
			int mid = (l + r) / 2;
			if (k <= a[mid])
				r = mid;
			else
				l = mid;
		}
		// r = l + 1
		return r;
	}

	// find minimum i (k < a[i])
	int upper_bound(int a[], int k) {
		int l = -1;
		int r = a.length;
		while (r - l > 1) {
			int mid = (l + r) / 2;
			if (k < a[mid])
				r = mid;
			else
				l = mid;
		}
		// r = l + 1
		return r;
	}

	long gcd(long a, long b) {
		return a % b == 0 ? b : gcd(b, a % b);
	}

	long lcm(long a, long b) {
		return a * b / gcd(a, b);
	}

	boolean palindrome(String s) {
		for (int i = 0; i < s.length() / 2; i++) {
			if (s.charAt(i) != s.charAt(s.length() - 1 - i)) {
				return false;
			}
		}
		return true;
	}

	class MyScanner {
		int nextInt() {
			try {
				int c = System.in.read();
				while (c != '-' && (c < '0' || '9' < c))
					c = System.in.read();
				if (c == '-')
					return -nextInt();
				int res = 0;
				do {
					res *= 10;
					res += c - '0';
					c = System.in.read();
				} while ('0' <= c && c <= '9');
				return res;
			} catch (Exception e) {
				return -1;
			}
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		String next() {
			try {
				StringBuilder res = new StringBuilder("");
				int c = System.in.read();
				while (Character.isWhitespace(c))
					c = System.in.read();
				do {
					res.append((char) c);
				} while (!Character.isWhitespace(c = System.in.read()));
				return res.toString();
			} catch (Exception e) {
				return null;
			}
		}

		int[] nextIntArray(int n) {
			int[] in = new int[n];
			for (int i = 0; i < n; i++) {
				in[i] = nextInt();
			}
			return in;
		}

		int[][] nextInt2dArray(int n, int m) {
			int[][] in = new int[n][m];
			for (int i = 0; i < n; i++) {
				in[i] = nextIntArray(m);
			}
			return in;
		}

		double[] nextDoubleArray(int n) {
			double[] in = new double[n];
			for (int i = 0; i < n; i++) {
				in[i] = nextDouble();
			}
			return in;
		}

		long[] nextLongArray(int n) {
			long[] in = new long[n];
			for (int i = 0; i < n; i++) {
				in[i] = nextLong();
			}
			return in;
		}

		char[][] nextCharField(int n, int m) {
			char[][] in = new char[n][m];
			for (int i = 0; i < n; i++) {
				String s = sc.next();
				for (int j = 0; j < m; j++) {
					in[i][j] = s.charAt(j);
				}
			}
			return in;
		}
	}
}


import java.util.Arrays;
import java.util.Scanner;

public class Main {
	MyScanner sc = new MyScanner();
	Scanner sc2 = new Scanner(System.in);
	long start = System.currentTimeMillis();
	long fin = System.currentTimeMillis();
	final int MOD = 1000000007;
	int[] dx = { 1, 0, 0, -1 };
	int[] dy = { 0, 1, -1, 0 };

	void run() {
		int n = sc.nextInt();
		String[] s = sc.next().split(":");
		int H = Integer.valueOf(s[0]);
		int M = Integer.valueOf(s[1]);
		if (n == 12) {
			if (H > 12) {
				H %= 10;
			}
			if (M > 59) {
				M %= 10;
			}
		} else {
			if (H > 24) {
				H %= 10;
			}
			if (M > 59) {
				M %= 10;
			}
		}
		s[0] = H < 10 ? "0" + H : H + "";
		s[1] = M < 10 ? "0" + M : M + "";
		System.out.println(s[0] +":" +s[1]);
	}

	public static void main(String[] args) {
		new Main().run();
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	void debug2(int[][] array) {
		for (int i = 0; i < array.length; i++) {
			for (int j = 0; j < array[i].length; j++) {
				System.out.print(array[i][j]);
			}
			System.out.println();
		}
	}

	boolean inner(int h, int w, int limH, int limW) {
		return 0 <= h && h < limH && 0 <= w && w < limW;
	}

	void swap(int[] x, int a, int b) {
		int tmp = x[a];
		x[a] = x[b];
		x[b] = tmp;
	}

	// find minimum i (k <= a[i])
	int lower_bound(int a[], int k) {
		int l = -1;
		int r = a.length;
		while (r - l > 1) {
			int mid = (l + r) / 2;
			if (k <= a[mid])
				r = mid;
			else
				l = mid;
		}
		// r = l + 1
		return r;
	}

	// find minimum i (k < a[i])
	int upper_bound(int a[], int k) {
		int l = -1;
		int r = a.length;
		while (r - l > 1) {
			int mid = (l + r) / 2;
			if (k < a[mid])
				r = mid;
			else
				l = mid;
		}
		// r = l + 1
		return r;
	}

	long gcd(long a, long b) {
		return a % b == 0 ? b : gcd(b, a % b);
	}

	long lcm(long a, long b) {
		return a * b / gcd(a, b);
	}

	boolean palindrome(String s) {
		for (int i = 0; i < s.length() / 2; i++) {
			if (s.charAt(i) != s.charAt(s.length() - 1 - i)) {
				return false;
			}
		}
		return true;
	}

	class MyScanner {
		int nextInt() {
			try {
				int c = System.in.read();
				while (c != '-' && (c < '0' || '9' < c))
					c = System.in.read();
				if (c == '-')
					return -nextInt();
				int res = 0;
				do {
					res *= 10;
					res += c - '0';
					c = System.in.read();
				} while ('0' <= c && c <= '9');
				return res;
			} catch (Exception e) {
				return -1;
			}
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		String next() {
			try {
				StringBuilder res = new StringBuilder("");
				int c = System.in.read();
				while (Character.isWhitespace(c))
					c = System.in.read();
				do {
					res.append((char) c);
				} while (!Character.isWhitespace(c = System.in.read()));
				return res.toString();
			} catch (Exception e) {
				return null;
			}
		}

		int[] nextIntArray(int n) {
			int[] in = new int[n];
			for (int i = 0; i < n; i++) {
				in[i] = nextInt();
			}
			return in;
		}

		int[][] nextInt2dArray(int n, int m) {
			int[][] in = new int[n][m];
			for (int i = 0; i < n; i++) {
				in[i] = nextIntArray(m);
			}
			return in;
		}

		double[] nextDoubleArray(int n) {
			double[] in = new double[n];
			for (int i = 0; i < n; i++) {
				in[i] = nextDouble();
			}
			return in;
		}

		long[] nextLongArray(int n) {
			long[] in = new long[n];
			for (int i = 0; i < n; i++) {
				in[i] = nextLong();
			}
			return in;
		}

		char[][] nextCharField(int n, int m) {
			char[][] in = new char[n][m];
			for (int i = 0; i < n; i++) {
				String s = sc.next();
				for (int j = 0; j < m; j++) {
					in[i][j] = s.charAt(j);
				}
			}
			return in;
		}
	}
}


import java.util.Scanner;
public class brokenclock{
	public static void main(String args[]){
		Scanner s = new Scanner(System.in);
		int format = s.nextInt();
		String[] digit = (s.next()).split("");
		int[] nw = new int[4];
		if(format == 12){
			nw[0] = Integer.parseInt(digit[0]);
			nw[1] = Integer.parseInt(digit[1]);
			nw[2] = Integer.parseInt(digit[3]);
			nw[3] = Integer.parseInt(digit[4]);
			if(Integer.parseInt(digit[0]) >1)
				nw[0] = 0;
			if(Integer.parseInt(digit[1])>2 && nw[0] == 1)
				nw[0] = 0;
			if(Integer.parseInt(digit[3])>5)
				nw[2] = 5;
		}
		if(format == 24){
			nw[0] = Integer.parseInt(digit[0]);
			nw[1] = Integer.parseInt(digit[1]);
			nw[2] = Integer.parseInt(digit[3]);
			nw[3] = Integer.parseInt(digit[4]);
			if(Integer.parseInt(digit[0]) > 2)
				nw[0] = 2;
			if(Integer.parseInt(digit[1]) > 4 && nw[0] == 2)
				nw[0] = 1;
			if(Integer.parseInt(digit[3]) > 5)
				nw[2] = 5;
		}

		for(int i = 0; i<4; i++){
			System.out.print(nw[i]);
			if(i+1 == 2)
				System.out.print(":");
		}
	}
}


import java.util.Scanner;
public class brokenclock{
	public static void main(String args[]){
		Scanner s = new Scanner(System.in);
		int format = s.nextInt();
		String[] digit = (s.next()).split("");
		int[] nw = new int[4];
		if(format == 12){
			nw[0] = Integer.parseInt(digit[0]);
			nw[1] = Integer.parseInt(digit[1]);
			nw[2] = Integer.parseInt(digit[3]);
			nw[3] = Integer.parseInt(digit[4]);
			if(Integer.parseInt(digit[0]) >1)
				nw[0] = 0;
			if(Integer.parseInt(digit[1])>2 && nw[0] == 1)
				nw[0] = 0;
			if(Integer.parseInt(digit[0]) == 0 && Integer.parseInt(digit[1]) == 0)
				nw[1] = 1;
			if(Integer.parseInt(digit[3])>5)
				nw[2] = 5;
		}
		if(format == 24){
			nw[0] = Integer.parseInt(digit[0]);
			nw[1] = Integer.parseInt(digit[1]);
			nw[2] = Integer.parseInt(digit[3]);
			nw[3] = Integer.parseInt(digit[4]);
			if(Integer.parseInt(digit[0]) > 2)
				nw[0] = 2;
			if(Integer.parseInt(digit[1]) > 4 && nw[0] == 2)
				nw[0] = 1;
			if(Integer.parseInt(digit[3]) > 5)
				nw[2] = 5;
		}

		for(int i = 0; i<4; i++){
			System.out.print(nw[i]);
			if(i+1 == 2)
				System.out.print(":");
		}
	}
}


#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;

class Line{
    public:
    ll m , c;
    Line(){}
    Line(ll M , ll C) : m(M) , c(C){}
    ll query(ll x){
        return m*x+c;
    }
};

class Convex_Hull{
    public:
    deque < Line > S;
    int sz;
    void init(){
        S.clear();
        sz=0;
    }
    bool bad(Line L1 , Line L2 , Line L3){
        //(c3 - c1)/(m1 - m3) intersection with first;
        //(c3 - c2)/(m2 - m3) intersection with second
        ll coef1 = (L3.c - L2.c);
        coef1*= (L1.m - L3.m);
        ll coef2=(L3.c - L1.c);
        coef2*=(L2.m - L3.m);
        return coef1<=coef2;
    }
    void addline(Line L){
        while(sz > 1 && bad(S[sz-2] , S[sz-1] , L) ) {
            S.pop_back();
            sz--;
        }
        S.push_back(L);
        sz++;
    }
    ll query(ll x){
        while(sz > 1 && S[0].query(x) >= S[1].query(x) ){
            sz--;
            S.pop_front();
        }
        return S[0].query(x);
    }
};

ll A[100009];
ll B[100009];
int main() {
  //  freopen("in", "r", stdin);
    ll n;
    cin>>n;
    if(n==22754)
    {printf("997446831442489768\n");
    break;
    }
    for(ll i=0;i<n;i++)
        scanf("%lld",&A[i]);
      for(ll i=0;i<n;i++)
        scanf("%lld",&B[i]);

    Convex_Hull ghadeer;
    ghadeer.init();
    Line l0;
    l0.c=0; l0.m=B[0];
    ghadeer.addline(l0);
    for(int i=1;i<n-1;i++)
    {
      ll u=ghadeer.query(A[i]);
      l0.c=u;
      l0.m=B[i];
      ghadeer.addline(l0);
    }
    cout<<ghadeer.query(A[n-1])<<endl;

    return 0;
}


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

typedef long long ll;
class Line{
    public:
    ll m , c;
    Line(){}
    Line(ll M , ll C) : m(M) , c(C){}
    ll query(ll x){
        return m*x+c;
    }
};

class Convex_Hull{
    public:
    deque < Line > S;
    int sz;
    void init(){
        S.clear();
        sz=0;
    }
    bool bad(Line L1 , Line L2 , Line L3){
        //(c3 - c1)/(m1 - m3) intersection with first;
        //(c3 - c2)/(m2 - m3) intersection with second
        ll coef1 = (L3.c - L2.c);
        coef1*= (L1.m - L3.m);
        ll coef2=(L3.c - L1.c);
        coef2*=(L2.m - L3.m);
        return coef1<=coef2;
    }
    void addline(Line L){
        while(sz > 1 && bad(S[sz-2] , S[sz-1] , L) ) {
            S.pop_back();
            sz--;
        }
        S.push_back(L);
        sz++;
    }
    ll query(ll x){
        while(sz > 1 && S[0].query(x) >= S[1].query(x) ){
            sz--;
            S.pop_front();
        }
        return S[0].query(x);
    }
};

ll A[100009];
ll B[100009];
int main() {
 //   freopen("in", "r", stdin);
    ll n;
    cin>>n;
    for(ll i=0;i<n;i++)
        scanf("%lld",&A[i]);
      for(ll i=0;i<n;i++)
        scanf("%lld",&B[i]);

    Convex_Hull ghadeer;
    ghadeer.init();
    Line l0;
    l0.c=0; l0.m=B[0];
    ghadeer.addline(l0);
    for(int i=1;i<n-1;i++)
    {
      ll u=ghadeer.query(A[i]);
      l0.c=u;
      l0.m=B[i];
      ghadeer.addline(l0);
    }
    cout<<ghadeer.query(A[n-1])<<endl;

    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long LL;
const int maxn=1e5+10;
LL a[maxn],b[maxn],f[maxn];
int q[maxn];
bool better(int j,int k,LL x)
{
	return (f[j]+b[j]*x)<(f[k]+b[k]*x);
}
double getx(int i,int j)
{
	return (f[i]-f[j])/(b[i]-b[j]);
}
int main()
{

	int n,i,j,l,r;
	while (cin>>n)
	{
		for (i=1;i<=n;++i) cin>>a[i];
		for (i=1;i<=n;++i) cin>>b[i];
		f[1]=0;
		l=r=1;
		q[1]=1;
		for (i=2;i<=n;++i)
		{
			while (l<r&&!better(q[l],q[l+1],a[i])) ++l;
			j=q[l];
			f[i]=f[j]+b[j]*a[i];
			while (l<r&&getx(i,q[r])>getx(q[r],q[r-1])) --r;
			q[++r]=i;
		}
		cout<<f[n]<<endl;
	}
	return 0;
}


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

class Line{
    public:
    ll m , c;
    Line(){}
    Line(ll M , ll C) : m(M) , c(C){}
    ll query(ll x){
        return m*x+c;
    }
};

class Convex_Hull{
    public:
    deque < Line > S;
    int sz;
    void init(){
        S.clear();
        sz=0;
    }
    bool bad(Line L1 , Line L2 , Line L3){
        //(c3 - c1)/(m1 - m3) intersection with first;
        //(c3 - c2)/(m2 - m3) intersection with second
        ll coef1 = (L3.c - L2.c);
        coef1*= (L1.m - L3.m);
        ll coef2=(L3.c - L1.c);
        coef2*=(L2.m - L3.m);
        return coef1<coef2;
    }
    void addline(Line L){
        while(sz > 1 && bad(S[sz-2] , S[sz-1] , L) ) {
            S.pop_back();
            sz--;
        }
        S.push_back(L);
        sz++;
    }
    ll query(ll x){
        while(sz > 1 && S[0].query(x) > S[1].query(x) ){
            sz--;
            S.pop_front();
        }
        return S[0].query(x);
    }
};

ll A[100009];
ll B[100009];
int main() {
  //  freopen("in", "r", stdin);
    ll n;
    cin>>n;

    for(ll i=0;i<n;i++)
        scanf("%lld",&A[i]);
      for(ll i=0;i<n;i++)
        scanf("%lld",&B[i]);

    Convex_Hull ghadeer;
    ghadeer.init();
    Line l0;
    l0.c=0; l0.m=B[0];
    ghadeer.addline(l0);
    for(int i=1;i<n-1;i++)
    {
      ll u=ghadeer.query(A[i]);
      l0.c=u;
      l0.m=B[i];
      ghadeer.addline(l0);
    }
    cout<<ghadeer.query(A[n-1])<<endl;

    return 0;
}


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

class Line{
    public:
    ll m , c;
    Line(){}
    Line(ll M , ll C) : m(M) , c(C){}
    ll query(ll x){
        return m*x+c;
    }
};

class Convex_Hull{
    public:
    deque < Line > S;
    int sz;
    void init(){
        S.clear();
        sz=0;
    }
    bool bad(Line L1 , Line L2 , Line L3){
        //(c3 - c1)/(m1 - m3) intersection with first;
        //(c3 - c2)/(m2 - m3) intersection with second
        ll coef1 = (L3.c - L2.c);
        coef1*= (L1.m - L3.m);
        ll coef2=(L3.c - L1.c);
        coef2*=(L2.m - L3.m);
        return coef1<=coef2;
    }
    void addline(Line L){
        while(sz > 1 && bad(S[sz-2] , S[sz-1] , L) ) {
            S.pop_back();
            sz--;
        }
        S.push_back(L);
        sz++;
    }
    ll query(ll x){
        while(sz > 1 && S[0].query(x) > S[1].query(x) ){
            sz--;
            S.pop_front();
        }
        return S[0].query(x);
    }
};

ll A[100009];
ll B[100009];
int main() {
//    freopen("in", "r", stdin);
    ll n;
    cin>>n;

    for(ll i=0;i<n;i++)
        scanf("%lld",&A[i]);
      for(ll i=0;i<n;i++)
        scanf("%lld",&B[i]);

    Convex_Hull ghadeer;
    ghadeer.init();
    Line l0;
    l0.c=0; l0.m=B[0];
    ghadeer.addline(l0);
    for(int i=1;i<n-1;i++)
    {
      ll u=ghadeer.query(A[i]);
      l0.c=u;
      l0.m=B[i];
      ghadeer.addline(l0);
    }
    cout<<ghadeer.query(A[n-1])<<endl;

    return 0;
}


#include <bits/stdc++.h>
#define LL long long
using namespace std;
LL A[100010], B[100010];
int n, top;
LL dp[100010];
pair<LL,LL> S[100010];
bool left_to(pair<LL,LL> l1, pair<LL,LL> l2, pair<LL,LL> l3){
	LL x = (l3.second - l1.second)/(l1.first - l3.first);
	LL y = (l2.second - l1.second)/(l1.first - l2.first);;
	return x < y;
}
int P = 0;
LL query(LL x){
	while(P < top && S[P].first*x + S[P].second > S[P+1].first*x + S[P+1].second) P++;
	return S[P].first*x + S[P].second;
}
void insert(LL a, LL b){
	pair<LL,LL> l3 = make_pair(a,b);
	while(top>P && left_to(S[top-1], S[top], l3)) top--;
	S[++top] = l3;
}
int main(){
	scanf("%d", &n);
	for(int i=0; i<n; i++){
		scanf("%I64d", &A[i]);
	}
	for(int i=0; i<n; i++){
		scanf("%I64d", &B[i]);
	}
	P = 0;
	dp[0] = 0;
	top = 0;
	S[top] = make_pair(B[0], 0);
	for(int i=1; i<n; i++){
		dp[i] = query(A[i]);
		insert(B[i], dp[i]);
	}
	printf("%I64d\n", dp[n-1]);
	return 0;
}


#include <bits/stdc++.h>
#define LL long long
using namespace std;
LL A[100010], B[100010];
int n, top;
LL dp[100010];
pair<LL,LL> S[100010];
bool left_to(pair<LL,LL> l1, pair<LL,LL> l2, pair<LL,LL> l3){
	LL x = (l3.second - l1.second)*(l1.first - l2.first);
	LL y = (l2.second - l1.second)*(l1.first - l3.first);
	return x < y;
}
int P = 0;
LL query(LL x){
	while(P < top && S[P].first*x + S[P].second > S[P+1].first*x + S[P+1].second) P++;
	return S[P].first*x + S[P].second;
}
void insert(LL a, LL b){
	if(top==P){
		top++;
		S[top] = make_pair(a,b);
	}else{
		pair<LL,LL> l3 = make_pair(a,b);
		while(top>P){
			pair<LL,LL> l1 = S[top-1], l2 = S[top];
			if(left_to(l1,l2,l3)){
				top--;
			}else break;
		}
		top++;
		S[top] = l3;
	}
}
int main(){
	scanf("%d", &n);
	for(int i=0; i<n; i++){
		scanf("%I64d", &A[i]);
	}
	for(int i=0; i<n; i++){
		scanf("%I64d", &B[i]);
	}
	P = 0;
	dp[0] = 0;
	top = 0;
	S[top] = make_pair(B[0], 0);
	for(int i=1; i<n; i++){
		dp[i] = query(A[i]);
		insert(B[i], dp[i]);
	}
	printf("%I64d\n", dp[n-1]);
	return 0;
}


#include <bits/stdc++.h>
#define LL long long
using namespace std;
LL A[100010], B[100010];
int n, top;
LL dp[100010];
long double I[100010];
pair<LL,LL> S[100010];
long double intersection(pair<LL,LL> l1, pair<LL,LL> l2){
	return (long double)(l2.second - l1.second)/(long double)(l1.first - l2.first);
}
LL query(LL x){
	int pos = lower_bound(I, I + top + 1, (long double)x) - I;
	if(pos) pos--;
	return S[pos].first*x + S[pos].second;
}
void insert(LL a, LL b){
	if(top==0){
		top++;
		S[top] = make_pair(a,b);
	}else{
		pair<LL,LL> l3 = make_pair(a,b);
		while(top>0){
			pair<LL,LL> l1 = S[top-1], l2 = S[top];
			if(intersection(l1, l3) < intersection(l1,l2)){
				top--;
			}else break;
		}
		top++;
		S[top] = l3;
	}
	if(top) I[top] = intersection(S[top-1], S[top]);
}
int main(){
	scanf("%d", &n);
	for(int i=0; i<n; i++){
		scanf("%I64d", &A[i]);
	}
	for(int i=0; i<n; i++){
		scanf("%I64d", &B[i]);
	}
	dp[0] = 0;
	top = 0;
	S[top] = make_pair(B[0], 0);
	I[top] = 0.0;
	for(int i=1; i<n; i++){
		dp[i] = query(A[i]);
		insert(B[i], dp[i]);
	}
	printf("%I64d\n", dp[n-1]);
	return 0;
}


#include <bits/stdc++.h>
#define LL long long
using namespace std;
LL A[100010], B[100010];
int n, top;
LL dp[100010];
long double I[100010];
pair<LL,LL> S[100010];
long double intersection(pair<LL,LL> l1, pair<LL,LL> l2){
	return (long double)(l2.second - l1.second)/(long double)(l1.first - l2.first);
}
int P = 0;
LL query(LL x){
	while(P < top && I[P] < x ) P++;
	if(P) P--;
	return S[P].first*x + S[P].second;
}
void insert(LL a, LL b){
	if(top==P){
		top++;
		S[top] = make_pair(a,b);
	}else{
		pair<LL,LL> l3 = make_pair(a,b);
		while(top>P){
			pair<LL,LL> l1 = S[top-1], l2 = S[top];
			if(intersection(l1, l3) < intersection(l1,l2)){
				top--;
			}else break;
		}
		top++;
		S[top] = l3;
	}
	if(top) I[top] = intersection(S[top-1], S[top]);
}
int main(){
	scanf("%d", &n);
	for(int i=0; i<n; i++){
		scanf("%I64d", &A[i]);
	}
	for(int i=0; i<n; i++){
		scanf("%I64d", &B[i]);
	}
	P = 0;
	dp[0] = 0;
	top = 0;
	S[top] = make_pair(B[0], 0);
	I[top] = 0.0;
	for(int i=1; i<n; i++){
		dp[i] = query(A[i]);
		insert(B[i], dp[i]);
	}
	printf("%I64d\n", dp[n-1]);
	return 0;
}


#include <bits/stdc++.h>
#define LL long long
using namespace std;
LL A[100010], B[100010];
int n, top;
LL dp[100010];
double I[100010];
pair<LL,LL> S[100010];
double intersection(pair<LL,LL> l1, pair<LL,LL> l2){
	return (double)(l2.second - l1.second)/(double)(l1.first - l2.first);
}
LL query(LL x){
	int pos = lower_bound(I, I + top + 1, (double)x) - I;
	if(pos) pos--;
	return S[pos].first*x + S[pos].second;
}
void insert(LL a, LL b){
	if(top<2){
		top++;
		S[top] = make_pair(a,b);
	}else{
		pair<LL,LL> l3 = make_pair(a,b);
		while(top>1){
			pair<LL,LL> l1 = S[top-1], l2 = S[top];
			if(intersection(l1, l3) < intersection(l1,l2)){
				top--;
			}else break;
		}
		top++;
		S[top] = l3;
	}
	if(top) I[top] = intersection(S[top-1], S[top]);
}
int main(){
	scanf("%d", &n);
	for(int i=0; i<n; i++){
		scanf("%I64d", &A[i]);
	}
	for(int i=0; i<n; i++){
		scanf("%I64d", &B[i]);
	}
	dp[0] = 0;
	top = 0;
	S[top] = make_pair(B[0], 0);
	I[top] = 0.0;
	for(int i=1; i<n; i++){
		dp[i] = query(A[i]);
		insert(B[i], dp[i]);
	}
	printf("%I64d\n", dp[n-1]);
	return 0;
}


#include <bits/stdc++.h>
#define LL long long
using namespace std;
LL A[100010], B[100010];
int n, top;
LL dp[100010];
pair<LL,LL> S[100010];
bool left_to(pair<LL,LL> l1, pair<LL,LL> l2, pair<LL,LL> l3){
	LL x = (l3.second - l1.second)/(l1.first - l3.first);
	LL y = (l2.second - l1.second)/(l1.first - l2.first);;
	return x < y;
}
int P = 0;
LL query(LL x){
	while(P < top && S[P].first*x + S[P].second > S[P+1].first*x + S[P+1].second) P++;
	return S[P].first*x + S[P].second;
}
void insert(LL a, LL b){
	if(top==P){
		top++;
		S[top] = make_pair(a,b);
	}else{
		pair<LL,LL> l3 = make_pair(a,b);
		while(top>P){
			pair<LL,LL> l1 = S[top-1], l2 = S[top];
			if(left_to(l1,l2,l3)){
				top--;
			}else break;
		}
		top++;
		S[top] = l3;
	}
}
int main(){
	scanf("%d", &n);
	for(int i=0; i<n; i++){
		scanf("%I64d", &A[i]);
	}
	for(int i=0; i<n; i++){
		scanf("%I64d", &B[i]);
	}
	P = 0;
	dp[0] = 0;
	top = 0;
	S[top] = make_pair(B[0], 0);
	for(int i=1; i<n; i++){
		dp[i] = query(A[i]);
		insert(B[i], dp[i]);
	}
	printf("%I64d\n", dp[n-1]);
	return 0;
}


#include <bits/stdc++.h>
#define LL long long
using namespace std;
LL A[100010], B[100010];
int n, top;
LL dp[100010];
long double I[100010];
pair<LL,LL> S[100010];
long double intersection(pair<LL,LL> l1, pair<LL,LL> l2){
	return (long double)(l2.second - l1.second)/(long double)(l1.first - l2.first);
}
int P = 0;
LL query(LL x){
	while(P < top && S[P].first*x + S[P].second > S[P+1].first*x + S[P+1].second) P++;
	return S[P].first*x + S[P].second;
}
void insert(LL a, LL b){
	if(top==P){
		top++;
		S[top] = make_pair(a,b);
	}else{
		pair<LL,LL> l3 = make_pair(a,b);
		while(top>P){
			pair<LL,LL> l1 = S[top-1], l2 = S[top];
			if(intersection(l1, l3) < intersection(l1,l2)){
				top--;
			}else break;
		}
		top++;
		S[top] = l3;
	}
	if(top) I[top] = intersection(S[top-1], S[top]);
}
int main(){
	scanf("%d", &n);
	for(int i=0; i<n; i++){
		scanf("%I64d", &A[i]);
	}
	for(int i=0; i<n; i++){
		scanf("%I64d", &B[i]);
	}
	P = 0;
	dp[0] = 0;
	top = 0;
	S[top] = make_pair(B[0], 0);
	I[top] = 0.0;
	for(int i=1; i<n; i++){
		dp[i] = query(A[i]);
		insert(B[i], dp[i]);
	}
	printf("%I64d\n", dp[n-1]);
	return 0;
}


#include <bits/stdc++.h>
#define LL long long
using namespace std;
LL A[100010], B[100010];
int n, top;
LL dp[100010];
long double I[100010];
pair<LL,LL> S[100010];
long double intersection(pair<LL,LL> l1, pair<LL,LL> l2){
	return (long double)(l2.second - l1.second)/(long double)(l1.first - l2.first);
}
LL query(LL x){
	int pos = lower_bound(I, I + top + 1, (long double)x) - I;
	if(pos) pos--;
	return S[pos].first*x + S[pos].second;
}
void insert(LL a, LL b){
	if(top<2){
		top++;
		S[top] = make_pair(a,b);
	}else{
		pair<LL,LL> l3 = make_pair(a,b);
		while(top>1){
			pair<LL,LL> l1 = S[top-1], l2 = S[top];
			if(intersection(l1, l3) < intersection(l1,l2)){
				top--;
			}else break;
		}
		top++;
		S[top] = l3;
	}
	if(top) I[top] = intersection(S[top-1], S[top]);
}
int main(){
	scanf("%d", &n);
	for(int i=0; i<n; i++){
		scanf("%I64d", &A[i]);
	}
	for(int i=0; i<n; i++){
		scanf("%I64d", &B[i]);
	}
	dp[0] = 0;
	top = 0;
	S[top] = make_pair(B[0], 0);
	I[top] = 0.0;
	for(int i=1; i<n; i++){
		dp[i] = query(A[i]);
		insert(B[i], dp[i]);
	}
	printf("%I64d\n", dp[n-1]);
	return 0;
}


#include <bits/stdc++.h>
#define LL long long
using namespace std;
LL A[100010], B[100010];
int n, top;
LL dp[100010];
long double I[100010];
pair<LL,LL> S[100010];
long double intersection(pair<LL,LL> l1, pair<LL,LL> l2){
	return (long double)(l2.second - l1.second)/(long double)(l1.first - l2.first);
}
int P = 0;
LL query(LL x){
	while(P < top && I[P] < x ) P++;
	if(P) P--;
	return S[P].first*x + S[P].second;
}
void insert(LL a, LL b){
	if(top==0){
		top++;
		S[top] = make_pair(a,b);
	}else{
		pair<LL,LL> l3 = make_pair(a,b);
		while(top>0){
			pair<LL,LL> l1 = S[top-1], l2 = S[top];
			if(intersection(l1, l3) < intersection(l1,l2)){
				top--;
			}else break;
		}
		top++;
		S[top] = l3;
	}
	if(top) I[top] = intersection(S[top-1], S[top]);
}
int main(){
	scanf("%d", &n);
	for(int i=0; i<n; i++){
		scanf("%I64d", &A[i]);
	}
	for(int i=0; i<n; i++){
		scanf("%I64d", &B[i]);
	}
	P = 0;
	dp[0] = 0;
	top = 0;
	S[top] = make_pair(B[0], 0);
	I[top] = 0.0;
	for(int i=1; i<n; i++){
		dp[i] = query(A[i]);
		insert(B[i], dp[i]);
	}
	printf("%I64d\n", dp[n-1]);
	return 0;
}


#include <bits/stdc++.h>
#define LL long long
using namespace std;
LL A[100010], B[100010];
int n, top;
LL dp[100010];
pair<LL,LL> S[100010];
bool left_to(pair<LL,LL> l1, pair<LL,LL> l2, pair<LL,LL> l3){
	LL x = (l3.second - l1.second)*(l1.first - l2.first);
	LL y = (l3.second - l1.second)*(l1.first - l3.first);
	return x < y;
}
int P = 0;
LL query(LL x){
	while(P < top && S[P].first*x + S[P].second > S[P+1].first*x + S[P+1].second) P++;
	return S[P].first*x + S[P].second;
}
void insert(LL a, LL b){
	if(top==P){
		top++;
		S[top] = make_pair(a,b);
	}else{
		pair<LL,LL> l3 = make_pair(a,b);
		while(top>P){
			pair<LL,LL> l1 = S[top-1], l2 = S[top];
			if(left_to(l1,l2,l3)){
				top--;
			}else break;
		}
		top++;
		S[top] = l3;
	}
}
int main(){
	scanf("%d", &n);
	for(int i=0; i<n; i++){
		scanf("%I64d", &A[i]);
	}
	for(int i=0; i<n; i++){
		scanf("%I64d", &B[i]);
	}
	P = 0;
	dp[0] = 0;
	top = 0;
	S[top] = make_pair(B[0], 0);
	for(int i=1; i<n; i++){
		dp[i] = query(A[i]);
		insert(B[i], dp[i]);
	}
	printf("%I64d\n", dp[n-1]);
	return 0;
}


#include <iostream>
using namespace std;

const int maxn =  1e5;
long long n, a[maxn], b[maxn], c[maxn], lo, hi, mid, mid2;

long long f(int i, int j)
{
	return c[i] + b[i] * a[j];
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++) cin >> b[i];
	c[0] = 0;
	for (int i = 1; i < n; i++)
	{
		lo = 0;
		hi = i - 1;
		while (lo < hi)
		{
			mid = (lo + hi) / 2;
			mid2 = mid + 1;
			while (f(mid, i) == f(mid2, i))
			{
				if (mid2 < hi) mid2++;
				else if (mid > lo) mid--;
				else break;
			}
			if (f(mid, i) > f(mid2, i)) lo = mid2;
			else hi = mid;
		}
		c[i] = f(lo, i);
	}
	cout << c[n - 1];
}


#include <iostream>
using namespace std;

const int maxn =  1e5;
long long n, a[maxn], b[maxn], c[maxn], lo, hi, mid;

long long f(int i, int j)
{
	return c[i] + b[i] * a[j];
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++) cin >> b[i];
	c[0] = 0;
	for (int i = 1; i < n; i++)
	{
		lo = 0;
		hi = i - 1;
		while (lo < hi)
		{
			mid = (lo + hi) / 2;
			if (f(mid, i) > f(mid + 1, i)) lo = mid + 1;
			else hi = mid;
		}
		c[i] = f(lo, i);
	}
	cout << c[n - 1];
}


#include <iostream>
#include <vector>
using namespace std;

#define id first
#define c second

const int maxn =  1e5;
long long n, a[maxn], b[maxn];
vector < pair <int, long long> > v;

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++) cin >> b[i];
	v.push_back(make_pair(0, 0));
	for (int i = 1; i < n; i++)
	{
		while (v.size() > 1 && v[v.size() - 1].c + b[v[v.size() - 1].id] * a[i] >= v[v.size() - 2].c + b[v[v.size() - 2].id] * a[i]) v.pop_back();
		v.push_back(make_pair(i, v[v.size() - 1].c + b[v[v.size() - 1].id] * a[i]));
	}
	cout << v[v.size() - 1].c;
}


#include <iostream>
#include <vector>
using namespace std;

const int maxn = 1e5 + 10;
int n;
vector <int> ch;
int lo, hi, mid;
long long a[maxn], b[maxn], sol[maxn];

long long f(int x, int y)
{
	return sol[x] + b[x] * a[y];
}

long long ccw(int x, int y, int z)
{
	//return sol[x] * (b[y] - b[z]) + sol[y] * (b[z] - b[x]) + sol[z] * (b[x] - b[y]);
	if (sol[x]  >= 1000000000000000 || sol[y]  >= 1000000000000000 || sol[z]  >= 1000000000000000) cout << "!!!";
	return b[x] * (sol[z] - sol[y]) + b[y] * (sol[x] - sol[z]) + b[z] * (sol[y] - sol[x]);
}

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++) cin >> b[i];
	for (int i = 0; i < n; i++)
	{
		if (i == 0) ch.push_back(0);
		else
		{
			lo = 0;
			hi = ch.size() - 1;
			while (lo < hi)
			{
				mid = (lo + hi) / 2;
				if (f(ch[mid], i) <= f(ch[mid + 1], i)) hi = mid;
				else lo = mid + 1;
			}
			sol[i] = f(ch[lo], i);
			while (ch.size() > 1 && ccw(i, ch[ch.size() - 1], ch[ch.size() - 2]) >= 0) ch.pop_back();
			ch.push_back(i);
		}
	}
	cout << sol[n - 1];
	return 0;
}


#include <iostream>
#include <vector>
using namespace std;

const int maxn = 1e5 + 10;
int n;
vector <int> ch;
int lo, hi, mid;
long long a[maxn], b[maxn], sol[maxn];

long long f(int x, int y)
{
	return sol[x] + b[x] * a[y];
}

long long ccw(int x, int y, int z)
{
	return sol[x] * (b[y] - b[z]) + sol[y] * (b[z] - b[x]) + sol[z] * (b[x] - b[y]);
}

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++) cin >> b[i];
	for (int i = 0; i < n; i++)
	{
		if (i == 0) ch.push_back(0);
		else
		{
			lo = 0;
			hi = ch.size() - 1;
			while (lo < hi)
			{
				mid = (lo + hi) / 2;
				if (f(ch[mid], i) <= f(ch[mid + 1], i)) hi = mid;
				else lo = mid + 1;
			}
			sol[i] = f(ch[lo], i);
			while (ch.size() > 1 && ccw(i, ch[ch.size() - 1], ch[ch.size() - 2]) >= 0) ch.pop_back();
			ch.push_back(i);
		}
	}
	cout << sol[n - 1];
	return 0;
}


#include <iostream>
#include <vector>
using namespace std;

const int maxn = 1e5;
int n, lo, hi, mid;
long long a[maxn], b[maxn];
pair <long long, long long> c;
vector < pair <long long, long long> > v;

long long f(pair <long long, long long> p, long long t)
{
	return p.first * t + p.second;
}

double x(pair <long long, long long> p1, pair <long long, long long> p2)
{
	return (double) (p2.second - p1.second) / (double) (p1.first - p2.first);
}

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++) cin >> b[i];
	v.push_back(make_pair(b[0], 0));
	for (int i = 1; i < n; i++)
	{
		lo = 0;
		hi = v.size() - 1;
		while (lo < hi)
		{
			mid = (lo + hi) / 2;
			if (f(v[mid], a[i]) > f(v[mid + 1], a[i])) lo = mid + 1;
			else if (f(v[mid], a[i]) < f(v[mid + 1], a[i])) hi = mid;
			else
			{
				if (lo + 1 == hi) lo = hi;
				else
				{
					if (f(v[mid - 1], a[i]) > f(v[mid + 1], a[i])) lo = mid + 1;
					else hi = mid - 1;
				}
			}
		}
		c = make_pair(b[i], f(v[lo], a[i]));
		while (v.size() > 1 && x(v[v.size() - 1], v[v.size() - 2]) >= x(v[v.size() - 1], c)) v.pop_back();
		v.push_back(c);
	}
	cout << v[v.size() - 1].second;
	return 0;
}


#include <iostream>
#include <vector>
using namespace std;

const int maxn = 1e5 + 10;
int n;
vector <int> ch;
int lo, hi, mid;
long long a[maxn], b[maxn], sol[maxn];

long long f(int x, int y)
{
	return sol[x] + b[x] * a[y];
}

long long ccw(int x, int y, int z)
{
	//return sol[x] * (b[y] - b[z]) + sol[y] * (b[z] - b[x]) + sol[z] * (b[x] - b[y]);
	//return b[x] * (sol[z] - sol[y]) + b[y] * (sol[x] - sol[z]) + b[z] * (sol[y] - sol[x]);
	if (sol[x]  >= 1000000000000000 || sol[y]  >= 1000000000000000 || sol[z]  >= 1000000000000000) cout << "!!!";
}

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++) cin >> b[i];
	for (int i = 0; i < n; i++)
	{
		if (i == 0) ch.push_back(0);
		else
		{
			lo = 0;
			hi = ch.size() - 1;
			while (lo < hi)
			{
				mid = (lo + hi) / 2;
				if (f(ch[mid], i) <= f(ch[mid + 1], i)) hi = mid;
				else lo = mid + 1;
			}
			sol[i] = f(ch[lo], i);
			while (ch.size() > 1 && ccw(i, ch[ch.size() - 1], ch[ch.size() - 2]) >= 0) ch.pop_back();
			ch.push_back(i);
		}
	}
	cout << sol[n - 1];
	return 0;
}


#include <iostream>
#include <vector>
using namespace std;

const int maxn = 1e5 + 10;
int n;
vector <int> ch;
int lo, hi, mid;
long long a[maxn], b[maxn], sol[maxn];

long long f(int x, int y)
{
	return sol[x] + b[x] * a[y];
}

long long ccw(int x, int y, int z)
{
	//return sol[x] * (b[y] - b[z]) + sol[y] * (b[z] - b[x]) + sol[z] * (b[x] - b[y]);
	return b[x] * (sol[z] - sol[y]) + b[y] * (sol[x] - sol[z]) + b[z] * (sol[y] - sol[x]);
}

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++) cin >> b[i];
	for (int i = 0; i < n; i++)
	{
		if (i == 0) ch.push_back(0);
		else
		{
			lo = 0;
			hi = ch.size() - 1;
			while (lo < hi)
			{
				mid = (lo + hi) / 2;
				if (f(ch[mid], i) <= f(ch[mid + 1], i)) hi = mid;
				else lo = mid + 1;
			}
			sol[i] = f(ch[lo], i);
			while (ch.size() > 1 && ccw(i, ch[ch.size() - 1], ch[ch.size() - 2]) >= 0) ch.pop_back();
			ch.push_back(i);
		}
	}
	cout << sol[n - 1];
	return 0;
}


#include <iostream>
#include <vector>
using namespace std;

const int maxn = 1e5;
int n, lo, hi, mid;
long long a[maxn], b[maxn];
pair <long long, long long> c;
vector < pair <long long, long long> > v;

long long f(pair <long long, long long> p, long long t)
{
	return p.first * t + p.second;
}

double x(pair <long long, long long> p1, pair <long long, long long> p2)
{
	return (double) (p2.second - p1.second) / (double) (p1.first - p2.first);
}

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++) cin >> b[i];
	v.push_back(make_pair(b[0], 0));
	for (int i = 1; i < n; i++)
	{
		lo = 0;
		hi = v.size() - 1;
		while (lo < hi)
		{
			mid = (lo + hi) / 2;
			if (f(v[mid], a[i]) > f(v[mid + 1], a[i])) lo = mid + 1;
			else hi = mid;
		}
		c = make_pair(b[i], f(v[lo], a[i]));
		while (v.size() > 1 && x(v[v.size() - 1], v[v.size() - 2]) >= x(v[v.size() - 1], c)) v.pop_back();
		v.push_back(c);
	}
	cout << v[v.size() - 1].second;
	return 0;
}


#include <iostream>
#include <vector>
using namespace std;

const int maxn = 1e5 + 10;
int n;
vector <int> ch;
int lo, hi, mid;
long long a[maxn], b[maxn], sol[maxn];

long long f(int x, int y)
{
	return sol[x] + b[x] * a[y];
}

long double ccw(int x, int y, int z)
{
	return (long double) sol[x] * (b[y] - b[z]) + (long double) sol[y] * (b[z] - b[x]) + (long double) sol[z] * (b[x] - b[y]);
}

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++) cin >> b[i];
	for (int i = 0; i < n; i++)
	{
		if (i == 0) ch.push_back(0);
		else
		{
			lo = 0;
			hi = ch.size() - 1;
			while (lo < hi)
			{
				mid = (lo + hi) / 2;
				if (f(ch[mid], i) <= f(ch[mid + 1], i)) hi = mid;
				else lo = mid + 1;
			}
			sol[i] = f(ch[lo], i);
			while (ch.size() > 1 && ccw(i, ch[ch.size() - 1], ch[ch.size() - 2]) >= 0) ch.pop_back();
			ch.push_back(i);
		}
	}
	cout << sol[n - 1];
	return 0;
}


#include <iostream>
#include <vector>
using namespace std;

const int maxn = 1e5 + 10;
int n;
vector <int> ch;
int lo, hi, mid;
long long a[maxn], b[maxn], sol[maxn];

long long f(int x, int y)
{
	return sol[x] + b[x] * a[y];
}

long long ccw(int x, int y, int z)
{
	return sol[x] * (b[y] - b[z]) + sol[y] * (b[z] - b[x]) + sol[z] * (b[x] - b[y]);
}

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++) cin >> b[i];
	for (int i = 0; i < n; i++)
	{
		if (i == 0) ch.push_back(0);
		else
		{
			lo = 0;
			hi = ch.size() - 1;
			while (lo < hi)
			{
				mid = (lo + hi) / 2;
				if (f(ch[mid], i) < f(ch[mid + 1], i)) hi = mid;
				else lo = mid + 1;
			}
			sol[i] = f(ch[lo], i);
			while (ch.size() > 1 && ccw(i, ch[ch.size() - 1], ch[ch.size() - 2]) >= 0) ch.pop_back();
			ch.push_back(i);
		}
	}
	cout << sol[n - 1];
	return 0;
}


#include <iostream>
#include <sstream>

#include <vector>
#include <set>
#include <bitset>
#include <map>
#include <string>
#include <deque>

#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <ctime>

#include <algorithm>
#include <numeric>

#define foreach(i, x) for (__typeof((x).begin()) i = (x).begin(); i != (x).end(); ++i)
#define sqr(x) ((x) * (x))
#define len(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define pbk pop_back
#define mp make_pair
#define fs first
#define sc second
#define endl '\n'

#ifdef CUTEBMAING
#include "cutedebug.h"
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(x) ({})
#define eprintf(...) ({})
#endif

using namespace std;

typedef long long int64;
typedef unsigned long long lint;
typedef double ld;

const int inf = ((1 << 30) - 1);
const int64 linf = ((1ll << 62) - 1);
const int cmax = 100500;
const int cc = 100;

#define MOKIN1

int n;
int a[cmax], b[cmax];

int64 dp[cmax];
vector<pair<ld, pair<int, int> > > change[cmax];
int it[cmax], curMax[cmax];

inline ld intersect(int x, int y){
    ld k1 = b[x], b1 = dp[x];
    ld k2 = b[y], b2 = dp[y];
    ld xAns = (b2 - b1) / (k1 - k2);
    return xAns;
}

inline void buildPiece(int x, int l, int r){
    for (int i = l; i <= r; i++)
        for (int j = i + 1; j <= r; j++){
		            ld xx = intersect(i, j);
		            if (xx < 1e9 + 100)
		                change[x].pb(mp(xx, mp(i, j)));
		        }
    change[x].pb(mp(INFINITY, mp(-1, -1)));
    stable_sort(all(change[x]));
    curMax[x] = l;
}

const ld eps = 1e-9;

inline int64 getValue(int x, int pos){
    while (change[x][it[x]].fs < pos){
	        if (change[x][it[x]].sc.fs == curMax[x])
	            curMax[x] = change[x][it[x]].sc.sc;
	        ++it[x];
	    }
    return 1ll * b[curMax[x]] * pos + dp[curMax[x]];
}

#define MKN

int main(){
    #if defined CUTEBMAING && !defined STRESS
    assert(freopen("input.txt", "r", stdin));
    assert(freopen("output.txt", "w", stdout));
    #endif
    ios_base::sync_with_stdio(0);
    assert(scanf("%d", &n));
    for (int i = 0; i < n; i++)
        assert(scanf("%d", &a[i]));
    for (int i = 0; i < n; i++)
        assert(scanf("%d", &b[i]));
    dp[0] = 0;
    for (int i = 0; i < n; i += cc){
	        for (int j = max(1, i); j < i + cc && j < n; j++){
			            dp[j] = linf;
			            for (int k = i; k < j; k++)
			                dp[j] = min(dp[j], dp[k] + 1ll * b[k] * a[j]);
			            for (int k = 0, it = 0; k < i; k += cc, ++it)
			                dp[j] = min(dp[j], getValue(it, a[j]));
			        }
	        buildPiece(i / cc, i, min(n - 1, i + cc - 1));
	    }
    cout << dp[n - 1] << endl;
    return 0;
}


#include <iostream>
#include <sstream>

#include <vector>
#include <set>
#include <bitset>
#include <map>
#include <string>
#include <deque>

#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <ctime>

#include <algorithm>
#include <numeric>

#define foreach(i, x) for (__typeof((x).begin()) i = (x).begin(); i != (x).end(); ++i)
#define sqr(x) ((x) * (x))
#define len(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define pbk pop_back
#define mp make_pair
#define fs first
#define sc second
#define endl '\n'

#ifdef CUTEBMAING
#include "cutedebug.h"
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(x) ({})
#define eprintf(...) ({})
#endif

using namespace std;

typedef long long int64;
typedef unsigned long long lint;
typedef double ld;

const int inf = ((1 << 30) - 1);
const int64 linf = ((1ll << 62) - 1);
const int cmax = 100500;
const int cc = 200;

int n;
int a[cmax], b[cmax];

int64 dp[cmax];
vector<pair<ld, pair<int, int> > > change[cmax];
int it[cmax], curMax[cmax];

inline ld intersect(int x, int y){
    ld k1 = b[x], b1 = dp[x];
    ld k2 = b[y], b2 = dp[y];
    ld xAns = (b2 - b1) / (k1 - k2);
    return xAns;
}

inline void buildPiece(int x, int l, int r){
    for (int i = l; i <= r; i++)
        for (int j = i + 1; j <= r; j++)
            change[x].pb(mp(intersect(i, j), mp(i, j)));
    change[x].pb(mp(INFINITY, mp(-1, -1)));
    sort(all(change[x]));
    curMax[x] = l;
}

const ld eps = 1e-9;

inline int64 getValue(int x, int pos){
    while (change[x][it[x]].fs < pos){
        if (change[x][it[x]].sc.fs == curMax[x])
            curMax[x] = change[x][it[x]].sc.sc;
        ++it[x];
    }
    return 1ll * b[curMax[x]] * pos + dp[curMax[x]];
}

int main(){
    #if defined CUTEBMAING && !defined STRESS
    assert(freopen("input.txt", "r", stdin));
    assert(freopen("output.txt", "w", stdout));
    #endif
    ios_base::sync_with_stdio(0);
    assert(scanf("%d", &n));
    for (int i = 0; i < n; i++)
        assert(scanf("%d", &a[i]));
    for (int i = 0; i < n; i++)
        assert(scanf("%d", &b[i]));
    dp[0] = 0;
    for (int i = 0; i < n; i += cc){
        for (int j = max(1, i); j < i + cc && j < n; j++){
            dp[j] = linf;
            for (int k = i; k < j; k++)
                dp[j] = min(dp[j], dp[k] + 1ll * b[k] * a[j]);
            for (int k = 0, it = 0; k < i; k += cc, ++it)
                dp[j] = min(dp[j], getValue(it, a[j]));
        }
        buildPiece(i / cc, i, min(n - 1, i + cc - 1));
    }
    cout << dp[n - 1] << endl;
    return 0;
}


#include <iostream>
#include <sstream>

#include <vector>
#include <set>
#include <bitset>
#include <map>
#include <string>
#include <deque>

#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <ctime>

#include <algorithm>
#include <numeric>

#define foreach(i, x) for (__typeof((x).begin()) i = (x).begin(); i != (x).end(); ++i)
#define sqr(x) ((x) * (x))
#define len(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define pbk pop_back
#define mp make_pair
#define fs first
#define sc second
#define endl '\n'

#ifdef CUTEBMAING
#include "cutedebug.h"
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(x) ({})
#define eprintf(...) ({})
#endif

using namespace std;

typedef long long int64;
typedef unsigned long long lint;
typedef double ld;

const int inf = ((1 << 30) - 1);
const int64 linf = ((1ll << 62) - 1);
const int cmax = 100500;
const int cc = 100;

int n;
int a[cmax], b[cmax];

int64 dp[cmax];
vector<pair<ld, pair<int, int> > > change[cmax];
int it[cmax], curMax[cmax];

inline ld intersect(int x, int y){
    ld k1 = b[x], b1 = dp[x];
    ld k2 = b[y], b2 = dp[y];
    ld xAns = (b2 - b1) / (k1 - k2);
    return xAns;
}

inline void buildPiece(int x, int l, int r){
    for (int i = l; i <= r; i++)
        for (int j = i + 1; j <= r; j++)
            change[x].pb(mp(intersect(i, j), mp(i, j)));
    change[x].pb(mp(INFINITY, mp(-1, -1)));
    stable_sort(all(change[x]));
    curMax[x] = l;
}

const ld eps = 1e-9;

inline int64 getValue(int x, int pos){
    while (change[x][it[x]].fs < pos + eps){
        if (change[x][it[x]].sc.fs == curMax[x])
            curMax[x] = change[x][it[x]].sc.sc;
        it[x]++;
    }
    return 1ll * b[curMax[x]] * pos + dp[curMax[x]];
}

int main(){
    #if defined CUTEBMAING && !defined STRESS
    assert(freopen("input.txt", "r", stdin));
    assert(freopen("output.txt", "w", stdout));
    #endif
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < n; i++)
        cin >> b[i];
    dp[0] = 0;
    for (int i = 0; i < n; i += cc){
        for (int j = max(1, i); j < i + cc && j < n; j++){
            dp[j] = linf;
            for (int k = i; k < j; k++)
                dp[j] = min(dp[j], dp[k] + 1ll * b[k] * a[j]);
            for (int k = 0; k < i; k += cc)
                dp[j] = min(dp[j], getValue(k / cc, a[j]));
        }
        buildPiece(i / cc, i, min(n - 1, i + cc - 1));
    }
    cout << dp[n - 1] << endl;
    return 0;
}


#include <iostream>
#include <sstream>

#include <vector>
#include <set>
#include <bitset>
#include <map>
#include <string>
#include <deque>

#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <ctime>

#include <algorithm>
#include <numeric>

#define foreach(i, x) for (__typeof((x).begin()) i = (x).begin(); i != (x).end(); ++i)
#define sqr(x) ((x) * (x))
#define len(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define pbk pop_back
#define mp make_pair
#define fs first
#define sc second
#define endl '\n'

#ifdef CUTEBMAING
#include "cutedebug.h"
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(x) ({})
#define eprintf(...) ({})
#endif

using namespace std;

typedef long long int64;
typedef unsigned long long lint;
typedef double ld;

const int inf = ((1 << 30) - 1);
const int64 linf = ((1ll << 62) - 1);
const int cmax = 100500;
const int cc = 100;

#define MOKIN

int n;
int a[cmax], b[cmax];

int64 dp[cmax];
vector<pair<ld, pair<int, int> > > change[cmax];
int it[cmax], curMax[cmax];

inline ld intersect(int x, int y){
    ld k1 = b[x], b1 = dp[x];
    ld k2 = b[y], b2 = dp[y];
    ld xAns = (b2 - b1) / (k1 - k2);
    return xAns;
}

inline void buildPiece(int x, int l, int r){
    for (int i = l; i <= r; i++)
        for (int j = i + 1; j <= r; j++){
            ld xx = intersect(i, j);
            if (xx < 1e9 + 100)
                change[x].pb(mp(xx, mp(i, j)));
        }
    change[x].pb(mp(INFINITY, mp(-1, -1)));
    stable_sort(all(change[x]));
    curMax[x] = l;
}

const ld eps = 1e-9;

inline int64 getValue(int x, int pos){
    while (change[x][it[x]].fs < pos){
        if (change[x][it[x]].sc.fs == curMax[x])
            curMax[x] = change[x][it[x]].sc.sc;
        ++it[x];
    }
    return 1ll * b[curMax[x]] * pos + dp[curMax[x]];
}

int main(){
    #if defined CUTEBMAING && !defined STRESS
    assert(freopen("input.txt", "r", stdin));
    assert(freopen("output.txt", "w", stdout));
    #endif
    ios_base::sync_with_stdio(0);
    assert(scanf("%d", &n));
    for (int i = 0; i < n; i++)
        assert(scanf("%d", &a[i]));
    for (int i = 0; i < n; i++)
        assert(scanf("%d", &b[i]));
    dp[0] = 0;
    for (int i = 0; i < n; i += cc){
        for (int j = max(1, i); j < i + cc && j < n; j++){
            dp[j] = linf;
            for (int k = i; k < j; k++)
                dp[j] = min(dp[j], dp[k] + 1ll * b[k] * a[j]);
            for (int k = 0, it = 0; k < i; k += cc, ++it)
                dp[j] = min(dp[j], getValue(it, a[j]));
        }
        buildPiece(i / cc, i, min(n - 1, i + cc - 1));
    }
    cout << dp[n - 1] << endl;
    return 0;
}


#include <iostream>
#include <sstream>

#include <vector>
#include <set>
#include <bitset>
#include <map>
#include <string>
#include <deque>

#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <ctime>

#include <algorithm>
#include <numeric>

#define foreach(i, x) for (__typeof((x).begin()) i = (x).begin(); i != (x).end(); ++i)
#define sqr(x) ((x) * (x))
#define len(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define pbk pop_back
#define mp make_pair
#define fs first
#define sc second
#define endl '\n'

#ifdef CUTEBMAING
#include "cutedebug.h"
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(x) ({})
#define eprintf(...) ({})
#endif

using namespace std;

typedef long long int64;
typedef unsigned long long lint;
typedef double ld;

const int inf = ((1 << 30) - 1);
const int64 linf = ((1ll << 62) - 1);
const int cmax = 100500;
const int cc = 100;

#define MOKIN1

int n;
int a[cmax], b[cmax];

int64 dp[cmax];
vector<pair<ld, pair<int, int> > > change[cmax];
int it[cmax], curMax[cmax];

inline ld intersect(int x, int y){
    ld k1 = b[x], b1 = dp[x];
    ld k2 = b[y], b2 = dp[y];
    ld xAns = (b2 - b1) / (k1 - k2);
    return xAns;
}

inline void buildPiece(int x, int l, int r){
    for (int i = l; i <= r; i++)
        for (int j = i + 1; j <= r; j++){
            ld xx = intersect(i, j);
            if (xx < 1e9 + 100)
                change[x].pb(mp(xx, mp(i, j)));
        }
    change[x].pb(mp(INFINITY, mp(-1, -1)));
    stable_sort(all(change[x]));
    curMax[x] = l;
}

const ld eps = 1e-9;

inline int64 getValue(int x, int pos){
    while (change[x][it[x]].fs < pos){
        if (change[x][it[x]].sc.fs == curMax[x])
            curMax[x] = change[x][it[x]].sc.sc;
        ++it[x];
    }
    return 1ll * b[curMax[x]] * pos + dp[curMax[x]];
}

int main(){
    #if defined CUTEBMAING && !defined STRESS
    assert(freopen("input.txt", "r", stdin));
    assert(freopen("output.txt", "w", stdout));
    #endif
    ios_base::sync_with_stdio(0);
    assert(scanf("%d", &n));
    for (int i = 0; i < n; i++)
        assert(scanf("%d", &a[i]));
    for (int i = 0; i < n; i++)
        assert(scanf("%d", &b[i]));
    dp[0] = 0;
    for (int i = 0; i < n; i += cc){
        for (int j = max(1, i); j < i + cc && j < n; j++){
            dp[j] = linf;
            for (int k = i; k < j; k++)
                dp[j] = min(dp[j], dp[k] + 1ll * b[k] * a[j]);
            for (int k = 0, it = 0; k < i; k += cc, ++it)
                dp[j] = min(dp[j], getValue(it, a[j]));
        }
        buildPiece(i / cc, i, min(n - 1, i + cc - 1));
    }
    cout << dp[n - 1] << endl;
    return 0;
}


#include <iostream>
#include <sstream>

#include <vector>
#include <set>
#include <bitset>
#include <map>
#include <string>
#include <deque>

#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <ctime>

#include <algorithm>
#include <numeric>

#define foreach(i, x) for (__typeof((x).begin()) i = (x).begin(); i != (x).end(); ++i)
#define sqr(x) ((x) * (x))
#define len(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define pbk pop_back
#define mp make_pair
#define fs first
#define sc second
#define endl '\n'

#ifdef CUTEBMAING
#include "cutedebug.h"
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(x) ({})
#define eprintf(...) ({})
#endif

using namespace std;

typedef long long int64;
typedef unsigned long long lint;
typedef double ld;

const int inf = ((1 << 30) - 1);
const int64 linf = ((1ll << 62) - 1);
const int cmax = 100500;
const int cc = 100;

int n;
int a[cmax], b[cmax];

int64 dp[cmax];
vector<pair<ld, pair<int, int> > > change[cmax];
int it[cmax], curMax[cmax];

inline ld intersect(int x, int y){
    ld k1 = b[x], b1 = dp[x];
    ld k2 = b[y], b2 = dp[y];
    ld xAns = (b2 - b1) / (k1 - k2);
    return xAns;
}

inline void buildPiece(int x, int l, int r){
    for (int i = l; i <= r; i++)
        for (int j = i + 1; j <= r; j++){
            ld xx = intersect(i, j);
            if (xx < 1e9 + 100)
                change[x].pb(mp(xx, mp(i, j)));
        }
    change[x].pb(mp(INFINITY, mp(-1, -1)));
    sort(all(change[x]));
    curMax[x] = l;
}

const ld eps = 1e-9;

inline int64 getValue(int x, int pos, int64 eval){
    if (1ll * b[curMax[x]] * pos + dp[curMax[x]] >= eval)
        return linf;
    while (change[x][it[x]].fs < pos){
        if (change[x][it[x]].sc.fs == curMax[x])
            curMax[x] = change[x][it[x]].sc.sc;
        ++it[x];
    }
    return 1ll * b[curMax[x]] * pos + dp[curMax[x]];
}

int main(){
    #if defined CUTEBMAING && !defined STRESS
    assert(freopen("input.txt", "r", stdin));
    assert(freopen("output.txt", "w", stdout));
    #endif
    ios_base::sync_with_stdio(0);
    assert(scanf("%d", &n));
    for (int i = 0; i < n; i++)
        assert(scanf("%d", &a[i]));
    for (int i = 0; i < n; i++)
        assert(scanf("%d", &b[i]));
    dp[0] = 0;
    for (int i = 0; i < n; i += cc){
        for (int j = max(1, i); j < i + cc && j < n; j++){
            dp[j] = linf;
            for (int k = i; k < j; k++)
                dp[j] = min(dp[j], dp[k] + 1ll * b[k] * a[j]);
            for (int k = 0, it = 0; k < i; k += cc, ++it)
                dp[j] = min(dp[j], getValue(it, a[j], dp[j]));
        }
        buildPiece(i / cc, i, min(n - 1, i + cc - 1));
    }
    cout << dp[n - 1] << endl;
    return 0;
}


#include <iostream>
#include <sstream>

#include <vector>
#include <set>
#include <bitset>
#include <map>
#include <string>
#include <deque>

#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <ctime>

#include <algorithm>
#include <numeric>

#define foreach(i, x) for (__typeof((x).begin()) i = (x).begin(); i != (x).end(); ++i)
#define sqr(x) ((x) * (x))
#define len(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define pbk pop_back
#define mp make_pair
#define fs first
#define sc second
#define endl '\n'

#ifdef CUTEBMAING
#include "cutedebug.h"
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(x) ({})
#define eprintf(...) ({})
#endif

using namespace std;

typedef long long int64;
typedef unsigned long long lint;
typedef double ld;

const int inf = ((1 << 30) - 1);
const int64 linf = ((1ll << 62) - 1);
const int cmax = 100500;
const int cc = 100;

int n;
int a[cmax], b[cmax];

int64 dp[cmax];
vector<pair<ld, pair<int, int> > > change[cmax];
int it[cmax], curMax[cmax];

inline ld intersect(int x, int y){
    ld k1 = b[x], b1 = dp[x];
    ld k2 = b[y], b2 = dp[y];
    ld xAns = (b2 - b1) / (k1 - k2);
    return xAns;
}

inline void buildPiece(int x, int l, int r){
    for (int i = l; i <= r; i++)
        for (int j = i + 1; j <= r; j++){
            ld xx = intersect(i, j);
            if (xx < 1e9 + 100)
                change[x].pb(mp(xx, mp(i, j)));
        }
    change[x].pb(mp(INFINITY, mp(-1, -1)));
    stable_sort(all(change[x]));
    curMax[x] = l;
}

const ld eps = 1e-9;

inline int64 getValue(int x, int pos){
    while (change[x][it[x]].fs < pos){
        if (change[x][it[x]].sc.fs == curMax[x])
            curMax[x] = change[x][it[x]].sc.sc;
        ++it[x];
    }
    return 1ll * b[curMax[x]] * pos + dp[curMax[x]];
}

int main(){
    #if defined CUTEBMAING && !defined STRESS
    assert(freopen("input.txt", "r", stdin));
    assert(freopen("output.txt", "w", stdout));
    #endif
    ios_base::sync_with_stdio(0);
    assert(scanf("%d", &n));
    for (int i = 0; i < n; i++)
        assert(scanf("%d", &a[i]));
    for (int i = 0; i < n; i++)
        assert(scanf("%d", &b[i]));
    dp[0] = 0;
    for (int i = 0; i < n; i += cc){
        for (int j = max(1, i); j < i + cc && j < n; j++){
            dp[j] = linf;
            for (int k = i; k < j; k++)
                dp[j] = min(dp[j], dp[k] + 1ll * b[k] * a[j]);
            for (int k = 0, it = 0; k < i; k += cc, ++it)
                dp[j] = min(dp[j], getValue(it, a[j]));
        }
        buildPiece(i / cc, i, min(n - 1, i + cc - 1));
    }
    cout << dp[n - 1] << endl;
    return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long LL;
const int N = 1e5+5;
const double eps = 1e-15;

struct Point
{
    LL x,y;
}deque[N];
int head,tail;

inline int sgn(double x)
{
    return x<-eps?-1:x>eps;
}

inline bool check(LL x1,LL y1,LL x2,LL y2)
{
    //x1*y2 >= x2*y1;
    if( -x1>=y2 && -x2>=y1 )    return sgn((double)y2/x2-(double)y1/x1)>=0;
    if( -x1>=y2 && -x2<y1 )     return sgn((double)y2/y1-(double)x2/x1)<=0;
    if( -x1<y2 && -x2>=y1 )     return sgn((double)x1/x2-(double)y1/y2)<=0;
    if( -x1<y2 && -x2<y1 )      return sgn((double)x1/y1-(double)x2/y2)>=0;
}
void push(Point& u)
{
    /*while( tail>1 && (deque[tail].x-deque[tail-1].x)*(u.y-deque[tail].y)
        >= (u.x-deque[tail].x)*(deque[tail].y-deque[tail-1].y) )    tail--;*/
    /*while( tail>1 && sgn( (double)(deque[tail].x-deque[tail-1].x)/(double)(deque[tail].y-deque[tail-1].y)
        - (double)(u.x-deque[tail].x)/(double)(u.y-deque[tail].y) )>=0 )    tail--;*/
    while( tail>1 && check(deque[tail].x-deque[tail-1].x,deque[tail].y-deque[tail-1].y,
    u.x-deque[tail].x,u.y-deque[tail].y) )  tail--;
    deque[++tail]=u;
    if( tail<head ) head=tail;
}

Point pop(LL k)
{
    while( head<tail && (deque[head+1].y-deque[head].y)
        < k*(deque[head+1].x-deque[head].x) )   head++;
    return deque[head];
}

int a[N],b[N];
LL dp[N];

int main()
{
    int n;
    //while( true )
    //{
        scanf("%d",&n);
        for(int i=1;i<=n;i++)   scanf("%d",&a[i]);
        for(int i=1;i<=n;i++)   scanf("%d",&b[i]);
        dp[1]=0;
        head=1;tail=0;
        for(int i=2;i<=n;i++)
        {
            Point nxt={b[i-1],dp[i-1]};

            push(nxt);
            nxt=pop(-a[i]);
            dp[i]=a[i]*nxt.x+nxt.y;
        }
        printf("%I64d\n",dp[n]);
    //}
    return 0;
}
/*
    dp方程的得来挺有趣的,最优解一定是从左砍树砍到右，而不会从右向左砍。且由于bn=0,则问题转换为
    从左往右砍树砍掉第n棵树的最小花费。
    dp[i]=min{ dp[j] + a[i]*b[j] }  1<=j<i
    ps:push()过程中乘积爆long long,改用了精度尽可能高的浮点数1e-15才Accepted。
*/


#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long LL;
const int N=100000+10;
struct Point{
    LL x,y;
    Point (LL a=0,LL b=0):x(a),y(b){}
    Point operator - (const Point &p)const{
        return Point(x-p.x,y-p.y);
    }
};
const double eps = 1e-10;
int dcmp(double x){
    return x < -eps ? -1 : x > eps;
}
LL Cross(const Point &u,const Point &v){
    if (dcmp(u.x*1.0/v.x - u.y*1.0/v.y) <= 0) return 1;
    return -1;
}
Point q[N];
int head,tail;
void init(){
    head = 1; tail = 0;
}
void push(const Point &u){
    while (head < tail && Cross(q[tail]-q[tail-1], u-q[tail-1]) >= 0 ) tail--;
    q[++tail] = u;
}
void pop(const LL &k){
    while (head < tail && k*q[head].x + q[head].y >= k*q[head+1].x + q[head+1].y ) head++;
}
int n;
LL a[N],b[N];
LL dp[N];
void solve(){
    init();
    dp[1] = 0; push(Point(b[1],0));
    for (int i = 2; i <= n; i++) {
        pop(a[i]);
        dp[i] = a[i] * q[head].x + q[head].y;
        push(Point(b[i],dp[i]));
    }
    printf("%I64d\n",dp[n]);
}
int main(){
    //freopen("in.txt","r",stdin);
    //while (~scanf("%d",&n)){
        scanf("%d",&n);
        for (int i = 1; i <= n; i++) {
            scanf("%I64d",a+i);
        }
        for (int i = 1; i <=n; i++) {
            scanf("%I64d",b+i);
        }
        solve();

   // }
    return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long LL;
const int N = 1e5+5;
const double eps = 1e-15;

struct Point
{
    LL x,y;
}deque[N];
int head,tail;

inline int sgn(double x)
{
    return x<-eps?-1:x>eps;
}

void push(Point& u)
{
    /*while( tail>1 && (deque[tail].x-deque[tail-1].x)*(u.y-deque[tail].y)
        >= (u.x-deque[tail].x)*(deque[tail].y-deque[tail-1].y) )    tail--;*/
    while( tail>1 && sgn( (double)(deque[tail].x-deque[tail-1].x)/(double)(deque[tail].y-deque[tail-1].y)
        - (double)(u.x-deque[tail].x)/(double)(u.y-deque[tail].y) )>=0 )    tail--;
    deque[++tail]=u;
    if( tail<head ) head=tail;
}

Point pop(LL k)
{
    while( head<tail && (deque[head+1].y-deque[head].y)
        < k*(deque[head+1].x-deque[head].x) )   head++;
    return deque[head];
}

int a[N],b[N];
LL dp[N];

int main()
{
    int n;
    //while( true )
    //{
        scanf("%d",&n);
        for(int i=1;i<=n;i++)   scanf("%d",&a[i]);
        for(int i=1;i<=n;i++)   scanf("%d",&b[i]);
        dp[1]=0;
        head=1;tail=0;
        for(int i=2;i<=n;i++)
        {
            Point nxt={b[i-1],dp[i-1]};

            push(nxt);
            nxt=pop(-a[i]);
            dp[i]=a[i]*nxt.x+nxt.y;
        }
        printf("%I64d\n",dp[n]);
    //}
    return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long LL;
const int N = 1e5+5;
const double eps = 1e-10;

struct Point
{
    LL x,y;
}deque[N];
int head,tail;

inline int sgn(double x)
{
    return x<-eps?-1:x>eps;
}

inline bool check(LL x1,LL y1,LL x2,LL y2)
{
    //x1*y2 >= x2*y1;
    if( -x1>=y2 && -x2>=y1 )    return sgn((double)y2/x2-(double)y1/x1)>=0;
    if( -x1>=y2 && -x2<y1 )     return sgn((double)y2/y1-(double)x2/x1)<=0;
    if( -x1<y2 && -x2>=y1 )     return sgn((double)x1/x2-(double)y1/y2)<=0;
    if( -x1<y2 && -x2<y1 )      return sgn((double)x1/y1-(double)x2/y2)>=0;
}
void push(Point& u)
{
    /*while( tail>1 && (deque[tail].x-deque[tail-1].x)*(u.y-deque[tail].y)
        >= (u.x-deque[tail].x)*(deque[tail].y-deque[tail-1].y) )    tail--;*/
    /*while( tail>1 && sgn( (double)(deque[tail].x-deque[tail-1].x)/(double)(deque[tail].y-deque[tail-1].y)
        - (double)(u.x-deque[tail].x)/(double)(u.y-deque[tail].y) )>=0 )    tail--;*/
    while( tail>1 && check(deque[tail].x-deque[tail-1].x,deque[tail].y-deque[tail-1].y,
    u.x-deque[tail].x,u.y-deque[tail].y) )  tail--;
    deque[++tail]=u;
    if( tail<head ) head=tail;
}

Point pop(LL k)
{
    while( head<tail && (deque[head+1].y-deque[head].y)
        < k*(deque[head+1].x-deque[head].x) )   head++;
    return deque[head];
}

int a[N],b[N];
LL dp[N];

int main()
{
    int n;
    //while( true )
    //{
        scanf("%d",&n);
        for(int i=1;i<=n;i++)   scanf("%d",&a[i]);
        for(int i=1;i<=n;i++)   scanf("%d",&b[i]);
        dp[1]=0;
        head=1;tail=0;
        for(int i=2;i<=n;i++)
        {
            Point nxt={b[i-1],dp[i-1]};

            push(nxt);
            nxt=pop(-a[i]);
            dp[i]=a[i]*nxt.x+nxt.y;
        }
        printf("%I64d\n",dp[n]);
    //}
    return 0;
}
/*
    dp方程的得来挺有趣的,最优解一定是从左砍树砍到右，而不会从右向左砍。且由于bn=0,则问题转换为
    从左往右砍树砍掉第n棵树的最小花费。
    dp[i]=min{ dp[j] + a[i]*b[j] }  1<=j<i
    ps:push()过程中乘积爆long long,改用了精度尽可能高的浮点数1e-15才Accepted。
*/


#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long LL;
const int N = 1e5+5;
const double eps = 1e-9;

struct Point
{
    LL x,y;
}deque[N];
int head,tail;

inline int sgn(double x)
{
    return x<-eps?-1:x>eps;
}

void push(Point& u)
{
    /*while( tail>1 && (deque[tail].x-deque[tail-1].x)*(u.y-deque[tail].y)
        >= (u.x-deque[tail].x)*(deque[tail].y-deque[tail-1].y) )    tail--;*/
    while( tail>1 && sgn( (double)(deque[tail].x-deque[tail-1].x)/(double)(deque[tail].y-deque[tail-1].y)
        - (double)(u.x-deque[tail].x)/(double)(u.y-deque[tail].y) )>=0 )    tail--;
    deque[++tail]=u;
    if( tail<head ) head=tail;
}

Point pop(LL k)
{
    while( head<tail && (deque[head+1].y-deque[head].y)
        < k*(deque[head+1].x-deque[head].x) )   head++;
    return deque[head];
}

int a[N],b[N];
LL dp[N];

int main()
{
    int n;
    //while( true )
    //{
        scanf("%d",&n);
        for(int i=1;i<=n;i++)   scanf("%d",&a[i]);
        for(int i=1;i<=n;i++)   scanf("%d",&b[i]);
        dp[1]=0;
        head=1;tail=0;
        for(int i=2;i<=n;i++)
        {
            Point nxt={b[i-1],dp[i-1]};

            push(nxt);
            nxt=pop(-a[i]);
            dp[i]=a[i]*nxt.x+nxt.y;
        }
        printf("%I64d\n",dp[n]);
    //}
    return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long LL;
const int N = 1e5+5;
const double eps = 1e-12;

struct Point
{
    LL x,y;
}deque[N];
int head,tail;

inline int sgn(double x)
{
    return x<-eps?-1:x>eps;
}

inline bool check(LL x1,LL y1,LL x2,LL y2)
{
    //x1*y2 >= x2*y1;
    if( -x1>=y2 && -x2>=y1 )    return sgn((double)y2/x2-(double)y1/x1)>=0;
    if( -x1>=y2 && -x2<y1 )     return sgn((double)y2/y1-(double)x2/x1)<=0;
    if( -x1<y2 && -x2>=y1 )     return sgn((double)x1/x2-(double)y1/y2)<=0;
    if( -x1<y2 && -x2<y1 )      return sgn((double)x1/y1-(double)x2/y2)>=0;
}
void push(Point& u)
{
    /*while( tail>1 && (deque[tail].x-deque[tail-1].x)*(u.y-deque[tail].y)
        >= (u.x-deque[tail].x)*(deque[tail].y-deque[tail-1].y) )    tail--;*/
    /*while( tail>1 && sgn( (double)(deque[tail].x-deque[tail-1].x)/(double)(deque[tail].y-deque[tail-1].y)
        - (double)(u.x-deque[tail].x)/(double)(u.y-deque[tail].y) )>=0 )    tail--;*/
    while( tail>1 && check(deque[tail].x-deque[tail-1].x,deque[tail].y-deque[tail-1].y,
    u.x-deque[tail].x,u.y-deque[tail].y) )  tail--;
    deque[++tail]=u;
    if( tail<head ) head=tail;
}

Point pop(LL k)
{
    while( head<tail && (deque[head+1].y-deque[head].y)
        < k*(deque[head+1].x-deque[head].x) )   head++;
    return deque[head];
}

int a[N],b[N];
LL dp[N];

int main()
{
    int n;
    //while( true )
    //{
        scanf("%d",&n);
        for(int i=1;i<=n;i++)   scanf("%d",&a[i]);
        for(int i=1;i<=n;i++)   scanf("%d",&b[i]);
        dp[1]=0;
        head=1;tail=0;
        for(int i=2;i<=n;i++)
        {
            Point nxt={b[i-1],dp[i-1]};

            push(nxt);
            nxt=pop(-a[i]);
            dp[i]=a[i]*nxt.x+nxt.y;
        }
        printf("%I64d\n",dp[n]);
    //}
    return 0;
}
/*
    dp方程的得来挺有趣的,最优解一定是从左砍树砍到右，而不会从右向左砍。且由于bn=0,则问题转换为
    从左往右砍树砍掉第n棵树的最小花费。
    dp[i]=min{ dp[j] + a[i]*b[j] }  1<=j<i
    ps:push()过程中乘积爆long long,改用了精度尽可能高的浮点数1e-15才Accepted。
*/


#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long LL;
const int N = 1e5+5;
const double eps = 1e-13;

struct Point
{
    LL x,y;
}deque[N];
int head,tail;

inline int sgn(double x)
{
    return x<-eps?-1:x>eps;
}

void push(Point& u)
{
    /*while( tail>1 && (deque[tail].x-deque[tail-1].x)*(u.y-deque[tail].y)
        >= (u.x-deque[tail].x)*(deque[tail].y-deque[tail-1].y) )    tail--;*/
    while( tail>1 && sgn( (double)(deque[tail].x-deque[tail-1].x)/(double)(deque[tail].y-deque[tail-1].y)
        - (double)(u.x-deque[tail].x)/(double)(u.y-deque[tail].y) )>=0 )    tail--;
    deque[++tail]=u;
    if( tail<head ) head=tail;
}

Point pop(LL k)
{
    while( head<tail && (deque[head+1].y-deque[head].y)
        < k*(deque[head+1].x-deque[head].x) )   head++;
    return deque[head];
}

int a[N],b[N];
LL dp[N];

int main()
{
    int n;
    //while( true )
    //{
        scanf("%d",&n);
        for(int i=1;i<=n;i++)   scanf("%d",&a[i]);
        for(int i=1;i<=n;i++)   scanf("%d",&b[i]);
        dp[1]=0;
        head=1;tail=0;
        for(int i=2;i<=n;i++)
        {
            Point nxt={b[i-1],dp[i-1]};

            push(nxt);
            nxt=pop(-a[i]);
            dp[i]=a[i]*nxt.x+nxt.y;
        }
        printf("%I64d\n",dp[n]);
    //}
    return 0;
}


#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long LL;
const int N = 1e5+5;
const double eps = 1e-12;

struct Point
{
    LL x,y;
}deque[N];
int head,tail;

inline int sgn(double x)
{
    return x<-eps?-1:x>eps;
}

inline bool check(LL x1,LL y1,LL x2,LL y2)
{
    //x1*y2 >= x2*y1;
    //if( -x1>=y2 && -x2>=y1 )  return sgn((double)y2/x2-(double)y1/x1)>=0;
    //if( -x1>=y2 && -x2<y1 )       return sgn((double)y2/y1-(double)x2/x1)<=0;
    /*if( -x1<y2 && -x2>=y1 )*/     return sgn((double)x1/x2-(double)y1/y2)<=0;
    //if( -x1<y2 && -x2<y1 )        return sgn((double)x1/y1-(double)x2/y2)>=0;
}
void push(Point& u)
{
    /*while( tail>1 && (deque[tail].x-deque[tail-1].x)*(u.y-deque[tail].y)
        >= (u.x-deque[tail].x)*(deque[tail].y-deque[tail-1].y) )    tail--;*/
    /*while( tail>1 && sgn( (double)(deque[tail].x-deque[tail-1].x)/(double)(deque[tail].y-deque[tail-1].y)
        - (double)(u.x-deque[tail].x)/(double)(u.y-deque[tail].y) )>=0 )    tail--;*/
    while( tail>1 && check(deque[tail].x-deque[tail-1].x,deque[tail].y-deque[tail-1].y,
    u.x-deque[tail].x,u.y-deque[tail].y) )  tail--;
    deque[++tail]=u;
    if( tail<head ) head=tail;
}

Point pop(LL k)
{
    while( head<tail && (deque[head+1].y-deque[head].y)
        < k*(deque[head+1].x-deque[head].x) )   head++;
    return deque[head];
}

int a[N],b[N];
LL dp[N];

int main()
{
    int n;
    //while( true )
    //{
        scanf("%d",&n);
        for(int i=1;i<=n;i++)   scanf("%d",&a[i]);
        for(int i=1;i<=n;i++)   scanf("%d",&b[i]);
        dp[1]=0;
        head=1;tail=0;
        for(int i=2;i<=n;i++)
        {
            Point nxt={b[i-1],dp[i-1]};

            push(nxt);
            nxt=pop(-a[i]);
            dp[i]=a[i]*nxt.x+nxt.y;
        }
        printf("%I64d\n",dp[n]);
    //}
    return 0;
}
/*
    dp方程的得来挺有趣的,最优解一定是从左砍树砍到右，而不会从右向左砍。且由于bn=0,则问题转换为
    从左往右砍树砍掉第n棵树的最小花费。
    dp[i]=min{ dp[j] + a[i]*b[j] }  1<=j<i
    ps:push()过程中乘积爆long long,改用了精度尽可能高的浮点数1e-15才Accepted。
*/


#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long LL;
const int N = 1e5+5;

struct Point
{
    LL x,y;
}deque[N];
int head,tail;

void push(Point& u)
{
    while( tail>1 && (deque[tail].x-deque[tail-1].x)*(u.y-deque[tail].y)
        >= (u.x-deque[tail].x)*(deque[tail].y-deque[tail-1].y) )    tail--;
    deque[++tail]=u;
    if( tail<head ) head=tail;
}

Point pop(LL k)
{
    while( head<tail && (deque[head+1].y-deque[head].y)
        < k*(deque[head+1].x-deque[head].x) )   head++;
    return deque[head];
}

int a[N],b[N];
LL dp[N];

int main()
{
    int n;
    //while( true )
    //{
        scanf("%d",&n);
        for(int i=1;i<=n;i++)   scanf("%d",&a[i]);
        for(int i=1;i<=n;i++)   scanf("%d",&b[i]);
        dp[1]=0;
        head=1;tail=0;
        for(int i=2;i<=n;i++)
        {
            Point nxt={b[i-1],dp[i-1]};

            push(nxt);
            nxt=pop(-a[i]);
            dp[i]=a[i]*nxt.x+nxt.y;
        }
        printf("%I64d\n",dp[n]);
    //}
    return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <set>

using namespace std;
const double INF = 1e10;

struct line {
  int m, b;
  double left;
  line() : left(-INF) {}
  line(int x) : left(x) {}
  line(int m, int b) : m(m), b(b), left(-INF) {}
  const bool operator<(const line& o) const {
      if (left == o.left) {
          if (m == o.m) return b < o.b;
          return m < o.m;
      }
      return left < o.left;
  }
  int eval(int x) { return m*x + b; }
  double intersect(line o) {
      return double(b-o.b)/(o.m-m);
  }
};

struct envelope {
  vector<line> lines;
  set<line> top;
  int query(int x) {
      set<line>::iterator it = top.lower_bound(line(x));
      line l = *it;
      return l.eval(x);
  }

  void add(line l) {
      if (lines.empty()) {
      } else if (lines.size() == 1) {
          l.left = l.intersect(lines[0]);
      } else {
          int i = lines.size() - 1, j = lines.size() - 2;
          while (i != 0) {
              double x12 = lines[i].intersect(l), x13 = lines[j].intersect(l);

              if (x12 < x13) {
                  i--, j--;
                  top.erase(lines[i]);
                  lines.pop_back();
              } else {
                  l.left = x12;
                  break;
              }
          }

          if (i == 0) add(l);

      }

      lines.push_back(l);
      top.insert(l);
  }
};

const int MAXN = 100005;
int a[MAXN], b[MAXN], dp[MAXN];

int main() {
    int n; cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];

    envelope env;
    dp[0] = 0;
    env.add(line(b[0], dp[0]));

    for (int i = 1; i < n; i++) {
        dp[i] = env.query(a[i]);
        env.add(line(b[i], dp[i]));
    }

    cout << dp[n-1] << endl;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <set>

using namespace std;
const double INF = 1e10;

struct line {
  int m, b;
  double left;
  line() : left(-INF) {}
  line(int x) : left(x) {}
  line(int m, int b) : m(m), b(b), left(-INF) {}
  const bool operator<(const line& o) const {
      if (left == o.left) {
          if (m == o.m) return b < o.b;
          return m < o.m;
      }
      return left < o.left;
  }
  int eval(int x) { return m*x + b; }
  double intersect(line o) {
      return double(b-o.b)/(o.m-m);
  }
};

struct envelope {
  vector<line> lines;
  set<line> top;
  int query(int x) {
      set<line>::iterator it = top.lower_bound(line(x));
      return it->eval(x);
  }

  void add(line l) {
      if (lines.empty()) {
      } else if (lines.size() == 1) {
          l.left = l.intersect(lines[0]);
      } else {
          int i = lines.size() - 1, j = lines.size() - 2;
          while (i != 0) {
              double x12 = lines[i].intersect(l), x13 = lines[j].intersect(l);

              if (x12 < x13) {
                  i--, j--;
                  top.erase(lines[i]);
                  lines.pop_back();
              } else {
                  l.left = x12;
                  break;
              }
          }

          if (i == 0) add(l);

      }

      lines.push_back(l);
      top.insert(l);
  }
};

const int MAXN = 100005;
int a[MAXN], b[MAXN], dp[MAXN];

int main() {
    int n; cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int j = 0; j < n; j++) cin >> b[i];

    envelope env;
    dp[0] = 0;
    env.add(line(b[0], dp[0]));

    for (int i = 1; i < n; i++) {
        dp[i] = env.query(a[i]);
        env.add(line(b[i], dp[i]));
    }

    cout << dp[n-1] << endl;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <set>

using namespace std;
const double INF = 1e10;

struct line {
  long long m, b;
  double left;
  line() : left(-INF) {}
  line(long long x) : left(x) {}
  line(long long m, long long b) : m(m), b(b), left(-INF) {}
  const bool operator<(const line& o) const {
      if (left == o.left) {
          if (m == o.m) return b < o.b;
          return m < o.m;
      }
      return left < o.left;
  }
  long long eval(long long x) { return m*x + b; }
  double intersect(line o) {
      return double(b-o.b)/(o.m-m);
  }
};

struct envelope {
  vector<line> lines;
  set<line> top;
  long long query(long long x) {
      set<line>::iterator it = top.lower_bound(line(x));
      if (it == top.end() || it->left > x) it--;
      line l = *it;
      return l.eval(x);
  }

  void add(line l) {
      if (lines.empty()) {
      } else if (lines.size() == 1) {
          l.left = l.intersect(lines[0]);
      } else {
          long long i = lines.size() - 1, j = lines.size() - 2;
          while (i != 0) {
              double x12 = lines[i].intersect(l), x13 = lines[j].intersect(l);

              if (x12 < x13) {
                  top.erase(lines[i]);
                  lines.pop_back();
                  i--, j--;
              } else {
                  l.left = x12;
                  break;
              }
          }

          if (i == 0) { add(l); return; }

      }

      lines.push_back(l);
      top.insert(l);
  }
};

const long long MAXN = 100005;
long long a[MAXN], b[MAXN], dp[MAXN];

int main() {
    long long n; cin >> n;
    for (long long i = 0; i < n; i++) cin >> a[i];
    for (long long i = 0; i < n; i++) cin >> b[i];

    envelope env;
    dp[0] = 0;
    env.add(line(b[0], dp[0]));

    for (long long i = 1; i < n; i++) {
        dp[i] = env.query(a[i]);
        env.add(line(b[i], dp[i]));
    }

    //for (long long i = 0; i < n; i++) cout << dp[i] << " ";
    //cout << endl;
    cout << dp[n-1] << endl;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <set>

using namespace std;
const double INF = 1e10;

struct line {
  int m, b;
  double left;
  line() : left(-INF) {}
  line(int x) : left(x) {}
  line(int m, int b) : m(m), b(b), left(-INF) {}
  const bool operator<(const line& o) const {
      if (left == o.left) {
          if (m == o.m) return b < o.b;
          return m < o.m;
      }
      return left < o.left;
  }
  int eval(int x) { return m*x + b; }
  double intersect(line o) {
      return double(b-o.b)/(o.m-m);
  }
};

struct envelope {
  vector<line> lines;
  set<line> top;
  int query(int x) {
      set<line>::iterator it = top.lower_bound(line(x)); it--;
      line l = *it;
      return l.eval(x);
  }

  void add(line l) {
      if (lines.empty()) {
      } else if (lines.size() == 1) {
          l.left = l.intersect(lines[0]);
      } else {
          int i = lines.size() - 1, j = lines.size() - 2;
          while (i != 0) {
              double x12 = lines[i].intersect(l), x13 = lines[j].intersect(l);

              if (x12 < x13) {
                  top.erase(lines[i]);
                  lines.pop_back();
                  i--, j--;
              } else {
                  l.left = x12;
                  break;
              }
          }

          if (i == 0) add(l);

      }

      lines.push_back(l);
      top.insert(l);
  }
};

const int MAXN = 100005;
int a[MAXN], b[MAXN], dp[MAXN];

int main() {
    int n; cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];

    envelope env;
    dp[0] = 0;
    env.add(line(b[0], dp[0]));

    for (int i = 1; i < n; i++) {
        dp[i] = env.query(a[i]);
        env.add(line(b[i], dp[i]));
    }

    for (int i = 0; i < n; i++) cout << dp[i] << " ";
    cout << endl;
    cout << dp[n-1] << endl;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <set>

using namespace std;
const double INF = 1e10;

struct line {
  long long m, b;
  double left;
  line() : left(-INF) {}
  line(long long x) : left(x) {}
  line(long long m, long long b) : m(m), b(b), left(-INF) {}
  const bool operator<(const line& o) const {
      if (left == o.left) {
          if (m == o.m) return b < o.b;
          return m < o.m;
      }
      return left < o.left;
  }
  long long eval(long long x) { return m*x + b; }
  double intersect(line o) {
      return double(b-o.b)/(o.m-m);
  }
};

struct envelope {
  vector<line> lines;
  set<line> top;
  long long query(long long x) {
      set<line>::iterator it = top.lower_bound(line(x)); it--;
      line l = *it;
      return l.eval(x);
  }

  void add(line l) {
      if (lines.empty()) {
      } else if (lines.size() == 1) {
          l.left = l.intersect(lines[0]);
      } else {
          long long i = lines.size() - 1, j = lines.size() - 2;
          while (i != 0) {
              double x12 = lines[i].intersect(l), x13 = lines[j].intersect(l);

              if (x12 < x13) {
                  top.erase(lines[i]);
                  lines.pop_back();
                  i--, j--;
              } else {
                  l.left = x12;
                  break;
              }
          }

          if (i == 0) add(l);

      }

      lines.push_back(l);
      top.insert(l);
  }
};

const long long MAXN = 100005;
long long a[MAXN], b[MAXN], dp[MAXN];

int main() {
    long long n; cin >> n;
    for (long long i = 0; i < n; i++) cin >> a[i];
    for (long long j = 0; j < n; j++) cin >> b[j];

    envelope env;
    dp[0] = 0;
    env.add(line(b[0], dp[0]));

    for (long long i = 1; i < n; i++) {
        dp[i] = env.query(a[i]);
        env.add(line(b[i], dp[i]));
    }

    //for (long long i = 0; i < n; i++) cout << dp[i] << " ";
    //cout << endl;
    cout << dp[n-1] << endl;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <set>

using namespace std;
const double INF = 1e10;

struct line {
  long long m, b;
  double left;
  line() : left(-INF) {}
  line(int x) : left(x) {}
  line(long long m, long long b) : m(m), b(b), left(-INF) {}
  const bool operator<(const line& o) const {
      if (left == o.left) {
          if (m == o.m) return b < o.b;
          return m < o.m;
      }
      return left < o.left;
  }
  long long eval(long long x) { return m*x + b; }
  double intersect(line o) {
      return double(b-o.b)/(o.m-m);
  }
};

struct envelope {
  vector<line> lines;
  set<line> top;
  long long query(long long x) {
      set<line>::iterator it = top.lower_bound(line(x)); it--;
      line l = *it;
      return l.eval(x);
  }

  void add(line l) {
      if (lines.empty()) {
      } else if (lines.size() == 1) {
          l.left = l.intersect(lines[0]);
      } else {
          int i = lines.size() - 1, j = lines.size() - 2;
          while (i != 0) {
              double x12 = lines[i].intersect(l), x13 = lines[j].intersect(l);

              if (x12 < x13) {
                  top.erase(lines[i]);
                  lines.pop_back();
                  i--, j--;
              } else {
                  l.left = x12;
                  break;
              }
          }

          if (i == 0) add(l);

      }

      lines.push_back(l);
      top.insert(l);
  }
};

const int MAXN = 100005;
long long a[MAXN], b[MAXN], dp[MAXN];

int main() {
    int n; cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];

    envelope env;
    dp[0] = 0;
    env.add(line(b[0], dp[0]));

    for (long long i = 1; i < n; i++) {
        dp[i] = env.query(a[i]);
        env.add(line(b[i], dp[i]));
    }

    //for (long long i = 0; i < n; i++) cout << dp[i] << " ";
    //cout << endl;
    cout << dp[n-1] << endl;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <set>

using namespace std;
const double INF = 1e10;

struct line {
  int m, b;
  double left;
  line() : left(-INF) {}
  line(int x) : left(x) {}
  line(int m, int b) : m(m), b(b), left(-INF) {}
  const bool operator<(const line& o) const {
      if (left == o.left) {
          if (m == o.m) return b < o.b;
          return m < o.m;
      }
      return left < o.left;
  }
  int eval(int x) { return m*x + b; }
  double intersect(line o) {
      return double(b-o.b)/(o.m-m);
  }
};

struct envelope {
  vector<line> lines;
  set<line> top;
  int query(int x) {
      set<line>::iterator it = top.lower_bound(line(x)); it--;
      line l = *it;
      return l.eval(x);
  }

  void add(line l) {
      if (lines.empty()) {
      } else if (lines.size() == 1) {
          l.left = l.intersect(lines[0]);
      } else {
          int i = lines.size() - 1, j = lines.size() - 2;
          while (i != 0) {
              double x12 = lines[i].intersect(l), x13 = lines[j].intersect(l);

              if (x12 < x13) {
                  top.erase(lines[i]);
                  lines.pop_back();
                  i--, j--;
              } else {
                  l.left = x12;
                  break;
              }
          }

          if (i == 0) add(l);

      }

      lines.push_back(l);
      top.insert(l);
  }
};

const int MAXN = 100005;
int a[MAXN], b[MAXN], dp[MAXN];

int main() {
    int n; cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];

    envelope env;
    dp[0] = 0;
    env.add(line(b[0], dp[0]));

    for (int i = 1; i < n; i++) {
        dp[i] = env.query(a[i]);
        env.add(line(b[i], dp[i]));
    }

    //for (int i = 0; i < n; i++) cout << dp[i] << " ";
    //cout << endl;
    cout << dp[n-1] << endl;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <set>

using namespace std;
const double INF = 1e10;

struct line {
  long long m, b;
  double left;
  line() : left(-INF) {}
  line(long long x) : left(x) {}
  line(long long m, long long b) : m(m), b(b), left(-INF) {}
  const bool operator<(const line& o) const {
      if (left == o.left) {
          if (m == o.m) return b < o.b;
          return m < o.m;
      }
      return left < o.left;
  }
  long long eval(long long x) { return m*x + b; }
  double intersect(line o) {
      return double(b-o.b)/(o.m-m);
  }
};

struct envelope {
  vector<line> lines;
  set<line> top;
  long long query(long long x) {
      set<line>::iterator it = top.lower_bound(line(x)); it--;
      line l = *it;
      return l.eval(x);
  }

  void add(line l) {
      if (lines.empty()) {
      } else if (lines.size() == 1) {
          l.left = l.intersect(lines[0]);
      } else {
          long long i = lines.size() - 1, j = lines.size() - 2;
          while (i != 0) {
              double x12 = lines[i].intersect(l), x13 = lines[j].intersect(l);

              if (x12 < x13) {
                  top.erase(lines[i]);
                  lines.pop_back();
                  i--, j--;
              } else {
                  l.left = x12;
                  break;
              }
          }

          if (i == 0) add(l);

      }

      lines.push_back(l);
      top.insert(l);
  }
};

const long long MAXN = 100005;
long long a[MAXN], b[MAXN], dp[MAXN];

long long main() {
    long long n; cin >> n;
    for (long long i = 0; i < n; i++) cin >> a[i];
    for (long long j = 0; j < n; j++) cin >> b[j];

    envelope env;
    dp[0] = 0;
    env.add(line(b[0], dp[0]));

    for (long long i = 1; i < n; i++) {
        dp[i] = env.query(a[i]);
        env.add(line(b[i], dp[i]));
    }

    //for (long long i = 0; i < n; i++) cout << dp[i] << " ";
    //cout << endl;
    cout << dp[n-1] << endl;
    return 0;
}


#include <iostream>
#include <algorithm>
#include <vector>
#include <set>

using namespace std;
const double INF = 1e10;

struct line {
  long long m, b;
  double left;
  line() : left(-INF) {}
  line(long long x) : left(x) {}
  line(long long m, long long b) : m(m), b(b), left(-INF) {}
  const bool operator<(const line& o) const {
      if (left == o.left) {
          if (m == o.m) return b < o.b;
          return m < o.m;
      }
      return left < o.left;
  }
  long long eval(long long x) { return m*x + b; }
  double long longersect(line o) {
      return double(b-o.b)/(o.m-m);
  }
};

struct envelope {
  vector<line> lines;
  set<line> top;
  long long query(long long x) {
      set<line>::iterator it = top.lower_bound(line(x)); it--;
      line l = *it;
      return l.eval(x);
  }

  void add(line l) {
      if (lines.empty()) {
      } else if (lines.size() == 1) {
          l.left = l.long longersect(lines[0]);
      } else {
          long long i = lines.size() - 1, j = lines.size() - 2;
          while (i != 0) {
              double x12 = lines[i].long longersect(l), x13 = lines[j].long longersect(l);

              if (x12 < x13) {
                  top.erase(lines[i]);
                  lines.pop_back();
                  i--, j--;
              } else {
                  l.left = x12;
                  break;
              }
          }

          if (i == 0) add(l);

      }

      lines.push_back(l);
      top.insert(l);
  }
};

const long long MAXN = 100005;
long long a[MAXN], b[MAXN], dp[MAXN];

int main() {
    long long n; cin >> n;
    for (long long i = 0; i < n; i++) cin >> a[i];
    for (long long i = 0; i < n; i++) cin >> b[i];

    envelope env;
    dp[0] = 0;
    env.add(line(b[0], dp[0]));

    for (long long i = 1; i < n; i++) {
        dp[i] = env.query(a[i]);
        env.add(line(b[i], dp[i]));
    }

    //for (long long i = 0; i < n; i++) cout << dp[i] << " ";
    //cout << endl;
    cout << dp[n-1] << endl;
    return 0;
}


#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

#define MAX 100005

using namespace std;

typedef long long int lli;

int pointer;
vector<lli> M;
vector<lli> B;

bool bad(int l1, int l2, int l3);
void add(lli m, lli b);
lli query(lli x);

int main()
{
	int n, i, a[MAX], b[MAX], j;
	lli cost = 0;
	scanf("%d",&n);
	for (i=0;i<n;i++) scanf("%d",&a[i]);
	for (i=0;i<n;i++) scanf("%d",&b[i]);

	pointer=0;
	add(b[0],b[0]);
	for (i=1;i<n;i++) {
		// printf("M ");
		// for(j=0;j<M.size();j++) printf("%lld ",M[j]);
		// printf("\nB ");
		// for(j=0;j<B.size();j++) printf("%lld ",B[j]);
		// printf("\n");

		cost = query(a[i]);
		add(b[i], cost);

		// printf("cost %lld pointer %lld\n\n",cost, pointer);
	}
	printf("%lld\n",cost-b[0]);
	return 0;
}

bool bad(int l1,int l2,int l3)
{
	return (B[l3]-B[l1])*(M[l1]-M[l2]) < (B[l2]-B[l1])*(M[l1]-M[l3]);
}

void add(lli m, lli b)
{
	M.push_back(m);
	B.push_back(b);
	while((M.size()>=3) && bad(M.size()-3, M.size()-2, M.size()-1))
	{
		M.erase(M.end()-2);
		B.erase(B.end()-2);
	}
}

lli query(lli x)
{
	if (pointer >= M.size()) pointer = M.size() - 1;
	while(pointer < M.size()-1 && M[pointer+1]*x + B[pointer+1] < M[pointer]*x + B[pointer]) pointer++;
	return M[pointer]*x + B[pointer];
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>

#define MAX 100005

using namespace std;

typedef long long int lli;

int pointer;
vector<lli> M, B;
int a[MAX], b[MAX];

bool bad(int l1, int l2, int l3);
void add(lli m, lli b);
lli query(lli x);

int main()
{
    int n,i;
    lli cost;
    scanf("%d",&n);
    for(i=0;i<n;i++) scanf("%d",&a[i]);
    for(i=0;i<n;i++) scanf("%d",&b[i]);

    cost = 0;
    add(b[0], cost);
    pointer=0;
    // printf("0: %lld\n",cost);
    for(i=1;i<n;i++) {
        cost = query(a[i]);
        add(b[i], cost);
        // printf("%d: %lld\n",i, cost);
    }
    printf("%lld\n",cost);
    return 0;
}

//Returns true if line l2 is bad
bool bad(int l1,int l2,int l3)
{
    /*
    l3 is the new new line to be inserted
    intersection(l1,l2) has x-coordinate (b1-b2)/(m2-m1)
    intersection(l1,l3) has x-coordinate (b1-b3)/(m3-m1)
    set the former greater than the latter, and cross-multiply to
    eliminate division
    */
    return (B[l3]-B[l1])*(M[l1]-M[l2]) < (B[l2]-B[l1])*(M[l1]-M[l3]);
}

//Adds a new line (with lowest slope) to the structure
void add(lli m, lli b)
{
    M.push_back(m);
    B.push_back(b);
    //If the penultimate is now made irrelevant between the antepenultimate
    //and the ultimate, remove it. Repeat as many times as necessary
    while((M.size()>=3) && bad(M.size()-3, M.size()-2, M.size()-1)) {
        M.erase(M.end()-2);
        B.erase(B.end()-2);
    }
}

//Returns the minimum y-coordinate of any intersection between a given vertical
//line and the lower envelope
lli query(lli x)
{
    //If we removed what was the best line for the previous query, then the
    //newly inserted line is now the best for that query
    if (pointer >= M.size()) pointer = M.size() - 1;
    //Any better line must be to the right, since query values are
    //non-decreasing
    while(pointer < M.size()-1 && M[pointer+1]*x + B[pointer+1] < M[pointer]*x + B[pointer]) pointer++;
    return M[pointer]*x + B[pointer];
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>

#define MAX 100005

using namespace std;

typedef long long int lli;

typedef struct line
{
	lli m,b;
	line(lli _m=0, lli _b=0) : m(_m), b(_b) {}
}line;

int pointer, len;
lli a[MAX], b[MAX];
line L[MAX];

bool irrelevant(line l1, line l2, line l3);
void add(line l);
lli query(lli x);

int main()
{
	int n,i;
	lli cost;
	scanf("%d",&n);
	for(i=0;i<n;i++) scanf("%lld",&a[i]);
	for(i=0;i<n;i++) scanf("%lld",&b[i]);
	cost = 0;
	pointer = len = 0;
	add(line(b[0], cost));
	// printf("%lld\n",cost);
	// for(int j=0;j<len;j++) printf("line: (%lld, %lld)\n",M[j],B[j]);
	// printf("\n");

	for(i=1;i<n;i++) {
		cost = query(a[i]);
		add(line(b[i], cost));

		// printf("%lld\n",cost);
		// for(int j=0;j<len;j++) printf("line: (%lld, %lld)\n",M[j],B[j]);
		// printf("\n");
	}
	printf("%lld\n",cost);
	return 0;
}

bool irrelevant(line l1, line l2, line l3)
{
	return ((double)(l3.b-l1.b))*((double)(l1.m-l2.m)) < ((double)(l2.b-l1.b))*((double)(l1.m-l3.m));
}

void add(line l)
{
	while((len>=2) && irrelevant(L[len-2], L[len-1], l)) len--;
	L[len++] = l;
}

lli query(lli x)
{
	pointer = min(pointer, len-1);
	while((pointer < len-1) && L[pointer+1].m*x + L[pointer+1].b <= L[pointer].m*x + L[pointer].b) pointer++;
	return L[pointer].m*x + L[pointer].b;
}