#include <bits/stdc++.h>
using namespace std;
int N;
long long A[100005], B[100005], dp[100005];
deque<int> q;
double f(int i, int j) { return (double)(dp[j] - dp[i]) / (B[i] - B[j]); }
int main() {
  cin >> N;
  for (int i = 0; i < N; i++) cin >> A[i];
  for (int i = 0; i < N; i++) cin >> B[i];
  memset(dp, 0x3f, sizeof dp);
  dp[0] = 0;
  q.push_back(0);
  int last = 0;
  for (int i = 1; i < N; i++) {
    while (q.size() >= 2) {
      int a = q.front();
      q.pop_front();
      int b = q.front();
      q.pop_front();
      if (f(a, b) <= A[i]) {
        q.push_front(b);
      } else {
        q.push_front(b);
        q.push_front(a);
        break;
      }
    }
    int x = q.front();
    dp[i] = dp[x] + 1LL * A[i] * B[x];
    while (q.size() >= 2) {
      int a = q.back();
      q.pop_back();
      int b = q.back();
      q.pop_back();
      if (f(b, a) < f(a, i)) {
        q.push_back(b);
        q.push_back(a);
        break;
      } else {
        q.push_back(b);
      }
    }
    q.push_back(i);
  }
  cout << dp[N - 1] << "\n";
}
