#include <bits/stdc++.h>
using namespace std;
long long dp[100005], a[100005], b[100005];
deque<int> in;
void find_dp(int x) {
  int minn = in.front();
  in.pop_front();
  while (1) {
    if (in.empty()) break;
    int tmp = in.front();
    if ((b[tmp] * a[x] + dp[tmp]) < (b[minn] * a[x] + dp[minn])) {
      minn = tmp;
      in.pop_front();
    } else
      break;
  }
  dp[x] = b[minn] * a[x] + dp[minn];
  in.push_front(minn);
}
void insert_d(int x) {
  int back1 = x;
  int back2 = in.back();
  in.pop_back();
  while (1) {
    if (in.empty()) break;
    int cmp = in.back();
    if (((dp[back1] - dp[cmp]) / (b[cmp] - b[back1])) <
        ((dp[back2] - dp[cmp]) / (b[cmp] - b[back2]))) {
      back2 = cmp;
      in.pop_back();
    } else
      break;
  }
  in.push_back(back2);
  in.push_back(back1);
}
int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) scanf("%lld", &a[i]);
  for (int i = 0; i < N; i++) scanf("%lld", &b[i]);
  dp[0] = 0;
  in.clear();
  in.push_back(0);
  for (int i = 1; i < N; i++) {
    find_dp(i);
    insert_d(i);
  }
  printf("%lld\n", dp[N - 1]);
}
