#include <bits/stdc++.h>
const int INF = (int)1e9;
const long long LINF = (long long)1e18;
const double EPS = 0.000000000000001;
const double PI = acos(-1.0);
const int MOD = 1e9 + 7;
using namespace std;
void fast_io() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
void file_in(const string& filename) { freopen(filename.c_str(), "r", stdin); }
void file_out(const string& filename) {
  freopen(filename.c_str(), "w", stdout);
}
double diffclock(clock_t clock1, clock_t clock2) {
  double diffticks = clock2 - clock1;
  return diffticks / ((double)CLOCKS_PER_SEC / 1000);
}
void sleep(int milliseconds) {
  clock_t start = clock();
  for (clock_t end = clock(); diffclock(start, end) < milliseconds;
       end = clock()) {
  }
}
struct Line {
  long long k;
  long long b;
  Line() : Line(0, 0) {}
  Line(long long k, long long b) : k(k), b(b) {}
};
long long cross(Line first, Line second) {
  return (second.b - first.b - 1) / (first.k - second.k) + 1;
}
void add_line(Line new_line, vector<Line>& lines, vector<long long>& points) {
  while (!points.empty() && (cross(lines.back(), new_line) < points.back())) {
    points.pop_back();
    lines.pop_back();
  }
  if (points.empty()) {
    points.push_back(-1);
  } else {
    points.push_back(cross(lines.back(), new_line));
  }
  lines.push_back(new_line);
}
long long get_value(int x, vector<Line>& lines, vector<long long>& points) {
  static int last_index = 0;
  while ((last_index + 1 < points.size()) && (points[last_index + 1] <= x)) {
    ++last_index;
  }
  return lines[last_index].k * x + lines[last_index].b;
}
void solve() {
  int n;
  cin >> n;
  vector<int> height(n);
  for (int i = 0; i < n; ++i) {
    cin >> height[i];
  }
  vector<int> cost(n);
  for (int i = 0; i < n; ++i) {
    cin >> cost[i];
  }
  vector<Line> lines;
  vector<long long> points;
  vector<long long> dp(n, LINF);
  dp[0] = 0;
  add_line(Line(cost[0], 0), lines, points);
  for (int i = 1; i < n; ++i) {
    dp[i] = get_value(height[i], lines, points);
    Line new_line(cost[i], dp[i]);
    add_line(new_line, lines, points);
  }
  cout << dp[n - 1] << '\n';
}
signed main() {
  fast_io();
  solve();
  return 0;
}
