#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9 + 7;
void warp() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
}
long long n;
double cross(pair<long long, long long> a, pair<long long, long long> b) {
  return -1.0 * ((double)(a.second - b.second) / (double)(a.first - b.first));
}
void push(vector<pair<long long, long long> > &st,
          pair<long long, long long> a) {
  while (st.size() > 1) {
    double prev = cross(st[st.size() - 2], st.back()),
           cur = cross(st.back(), a);
    if (cur < prev)
      st.pop_back();
    else
      break;
  }
  st.push_back(a);
}
long long get(vector<pair<long long, long long> > &st, long long x) {
  if (st.size() == 1) return st[0].first * x + st[0].second;
  double temp = cross(st[0], st[1]);
  if (x <= temp) return st[0].first * x + st[0].second;
  long long l = 0, r = st.size() - 1;
  while (r - l > 1) {
    long long m = (l + r) / 2;
    temp = cross(st[m], st[m + 1]);
    if (x <= temp)
      r = m;
    else
      l = m;
  }
  return st[r].first * x + st[r].second;
}
long long solve(vector<long long> &a, vector<long long> &b) {
  vector<long long> dp(n);
  dp[0] = 0;
  vector<pair<long long, long long> > hull;
  push(hull, make_pair(b[0], 0));
  for (long long i = 1; i < n; i++) {
    dp[i] = get(hull, a[i]);
    push(hull, make_pair(b[i], dp[i]));
  }
  return dp.back();
}
signed main() {
  warp();
  cin >> n;
  vector<long long> a(n);
  vector<long long> b(n);
  for (long long i = 0; i < n; i++) cin >> a[i];
  for (long long i = 0; i < n; i++) cin >> b[i];
  cout << solve(a, b) << endl;
  return 0;
}
