#include <bits/stdc++.h>
using namespace std;
const long long N = 100005;
long long A[N], B[N], dp[N];
struct ConvexHullDynamic {
  static const long long INF = 1e18;
  struct Line {
    long long a, b;
    double xLeft;
    enum Type { line, maxQuery, minQuery } type;
    long long val;
    explicit Line(long long aa = 0, long long bb = 0)
        : a(aa), b(bb), xLeft(-INF), type(Type::line), val(0) {}
    long long valueAt(long long x) const { return a * x + b; }
    friend bool isParallel(const Line &l1, const Line &l2) {
      return l1.a == l2.a;
    }
    friend double intersectX(const Line &l1, const Line &l2) {
      return isParallel(l1, l2) ? INF : 1.0 * (l2.b - l1.b) / (l1.a - l2.a);
    }
    bool operator<(const Line &l2) const {
      if (l2.type == line) return this->a < l2.a;
      if (l2.type == maxQuery) return this->xLeft < l2.val;
      if (l2.type == minQuery) return this->xLeft > l2.val;
    }
  };
  bool isMax;
  set<Line> hull;
  bool hasPrev(set<Line>::iterator it) { return it != hull.begin(); }
  bool hasNext(set<Line>::iterator it) {
    return it != hull.end() && next(it) != hull.end();
  }
  bool irrelevant(const Line &l1, const Line &l2, const Line &l3) {
    return intersectX(l1, l3) <= intersectX(l1, l2);
  }
  bool irrelevant(set<Line>::iterator it) {
    return hasPrev(it) && hasNext(it) &&
           ((isMax && irrelevant(*prev(it), *it, *next(it))) ||
            (!isMax && irrelevant(*next(it), *it, *prev(it))));
  }
  set<Line>::iterator updateLeftBorder(set<Line>::iterator it) {
    if (isMax && !hasPrev(it) || !isMax && !hasNext(it)) return it;
    double val = intersectX(*it, isMax ? (*prev(it)) : (*next(it)));
    Line temp(*it);
    it = hull.erase(it);
    temp.xLeft = val;
    it = hull.insert(it, temp);
    return it;
  }
  explicit ConvexHullDynamic(bool isMax) : isMax(isMax) {}
  void addLine(long long a, long long b) {
    Line l3 = Line(a, b);
    auto it = hull.lower_bound(l3);
    if (it != hull.end() && isParallel(*it, l3)) {
      if (isMax && it->b < b || !isMax && it->b > b)
        it = hull.erase(it);
      else
        return;
    }
    it = hull.insert(it, l3);
    if (irrelevant(it)) {
      hull.erase(it);
      return;
    }
    while (hasPrev(it) && irrelevant(prev(it))) hull.erase(prev(it));
    while (hasNext(it) && irrelevant(next(it))) hull.erase(next(it));
    it = updateLeftBorder(it);
    if (hasPrev(it)) updateLeftBorder(prev(it));
    if (hasNext(it)) updateLeftBorder(next(it));
  }
  long long getBest(long long x) {
    Line q;
    q.val = x;
    q.type = isMax ? Line::Type::maxQuery : Line::Type::minQuery;
    auto bestLine = hull.lower_bound(q);
    if (isMax) --bestLine;
    return bestLine->valueAt(x);
  }
};
ConvexHullDynamic hull(0);
void solve() {
  long long n;
  cin >> n;
  for (__typeof((n)) i = (1); i <= (n); i++) cin >> A[i];
  for (__typeof((n)) i = (1); i <= (n); i++) cin >> B[i];
  dp[1] = 0;
  hull.addLine(B[1], dp[1]);
  for (__typeof((n)) i = (2); i <= (n); i++) {
    dp[i] = hull.getBest(A[i]);
    hull.addLine(B[i], dp[i]);
  }
  cout << dp[n] << '\n';
}
signed main() {
  long long t;
  ios_base::sync_with_stdio(false);
  t = 1;
  while (t--) solve();
  return 0;
}
