#include <bits/stdc++.h>
using namespace std;
const long long inf = 2e18;
struct LiChao_min {
  struct line {
    int64_t a, b;
    line() {
      a = 0;
      b = 0;
    }
    line(int64_t _a, int64_t _b) {
      a = _a;
      b = _b;
    }
    int64_t eval(int x) { return a * x + b; }
  };
  struct node {
    node *l, *r;
    line f;
    node() {
      f = line();
      l = nullptr;
      r = nullptr;
    }
    node(int64_t a, int64_t b) {
      f = line(a, b);
      l = nullptr;
      r = nullptr;
    }
    node(line v) {
      f = v;
      l = nullptr;
      r = nullptr;
    }
  };
  typedef node *pnode;
  pnode root;
  int sz;
  void init(int _sz) {
    sz = _sz + 1;
    root = nullptr;
  }
  void add_line(int64_t a, int64_t b) {
    line v = line(a, b);
    insert(v, -sz, sz, root);
  }
  int64_t query(int x) { return query(x, -sz, sz, root); }
  void insert(line &v, int l, int r, pnode &nd) {
    if (!nd) {
      nd = new node(v);
      return;
    }
    int64_t trl = nd->f.eval(l), trr = nd->f.eval(r);
    int64_t vl = v.eval(l), vr = v.eval(r);
    if (trl <= vl && trr <= vr) return;
    if (trl > vl && trr > vr) {
      nd->f = v;
      return;
    }
    int mid = (l + r) >> 1;
    if (trl > vl) swap(nd->f, v);
    if (nd->f.eval(mid) < v.eval(mid))
      insert(v, mid + 1, r, nd->r);
    else
      swap(nd->f, v), insert(v, l, mid, nd->l);
  }
  int64_t query(int x, int l, int r, pnode &nd) {
    if (!nd) return inf;
    if (l == r) return nd->f.eval(x);
    int mid = (l + r) >> 1;
    if (mid >= x) return min(nd->f.eval(x), query(x, l, mid, nd->l));
    return min(nd->f.eval(x), query(x, mid + 1, r, nd->r));
  }
};
LiChao_min tree;
int main() {
  int n;
  scanf("%d", &n);
  long long a[n], b[n], dp[n];
  for (int i = 0; i < n; ++i) scanf("%I64d", &a[i]);
  for (int i = 0; i < n; ++i) scanf("%I64d", &b[i]);
  tree.init(1e9);
  dp[0] = 0;
  tree.add_line(b[0], dp[0]);
  for (int i = 1; i < n; ++i) {
    dp[i] = tree.query(a[i]);
    tree.add_line(b[i], dp[i]);
  }
  return printf("%I64d", dp[n - 1]), 0;
}
