#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int a[N], b[N];
long long dp[N];
struct point {
  long long x, y;
  point operator-(point b) { return {x - b.x, y - b.y}; }
};
bool ccw(point a, point b) {
  return (long double)a.x * b.y - (long double)a.y * b.x >= 0;
}
bool ccw(point a, point b, point c) { return ccw(b - a, c - b); }
inline void Main() {
  int n;
  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]);
  int best = 0;
  vector<point> stk;
  for (int i = 1; i <= n; i++) {
    if (i == 1) {
      dp[i] = 0;
    } else {
      while (best + 1 < ((int)(stk).size()) &&
             stk[best].x * 1LL * a[i] + stk[best].y >=
                 stk[best + 1].x * 1LL * a[i] + stk[best + 1].y)
        best++;
      dp[i] = stk[best].x * 1LL * a[i] + stk[best].y;
    }
    point nxt = {b[i], dp[i]};
    while (((int)(stk).size()) > 1 &&
           ccw(stk[((int)(stk).size()) - 2], stk[((int)(stk).size()) - 1], nxt))
      stk.pop_back();
    stk.push_back(nxt);
  }
  printf("%lld\n", dp[n]);
}
int main() {
  Main();
  return 0;
}
