#include <bits/stdc++.h>
using namespace std;
long double pointofintersection(int m1, long long int c1, int m2,
                                long long int c2) {
  long long int num = c2 - c1;
  long long int den = m1 - m2;
  return num / (long double)den;
}
int popold(int old, int older, int cur, vector<long long int> &c,
           vector<int> &m) {
  long long int num1 = c[older] - c[old];
  long long int den1 = m[old] - m[older];
  long double x1 = num1 / (long double)den1;
  long long int num2 = c[cur] - c[older];
  long long int den2 = m[older] - m[cur];
  long double x2 = num2 / (long double)den2;
  return x2 < x1;
}
long long int binary_search(const vector<int> &lines,
                            vector<long long int> &cost, vector<int> &m,
                            const long long int x) {
  if (lines.size() == 1) {
    return cost[lines[0]] + m[lines[0]] * x;
  }
  int n = lines.size();
  long double lt = pointofintersection(m[lines[0]], cost[lines[0]], m[lines[1]],
                                       cost[lines[1]]);
  long double rt = pointofintersection(m[lines[n - 1]], cost[lines[n - 1]],
                                       m[lines[n - 2]], cost[lines[n - 2]]);
  if (x <= lt) return cost[lines[0]] + m[lines[0]] * x;
  if (x >= rt) return cost[lines[n - 1]] + m[lines[n - 1]] * x;
  int lo = 1, hi = n - 2;
  int ans;
  while (hi >= lo) {
    int mid = (hi + lo) / 2;
    long double crit =
        pointofintersection(m[lines[mid]], cost[lines[mid]], m[lines[mid + 1]],
                            cost[lines[mid + 1]]);
    if (x <= crit) {
      ans = mid;
      hi = mid - 1;
    } else {
      lo = mid + 1;
    }
  }
  return cost[lines[ans]] + m[lines[ans]] * x;
}
int main() {
  int n;
  cin >> n;
  vector<int> a, b, s;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    a.push_back(x);
  }
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    b.push_back(x);
  }
  s.push_back(0);
  vector<long long int> cost(n, 0);
  for (int i = 1; i < n; ++i) {
    cost[i] = binary_search(s, cost, b, a[i]);
    while (s.size() > 1) {
      int old = s[s.size() - 1];
      int older = s[s.size() - 2];
      if (popold(old, older, i, cost, b))
        s.pop_back();
      else
        break;
    }
    s.push_back(i);
  }
  cout << cost[n - 1] << endl;
  return 0;
}
