#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9 + 7;
template <typename S, typename T>
ostream& operator<<(ostream& out, pair<S, T> const& p) {
  out << '(' << p.f << ", " << p.s << ')';
  return out;
}
template <typename T>
ostream& operator<<(ostream& out, vector<T> const& v) {
  long long int l = v.size();
  for (long long int i = 0; i < l - 1; i++) out << v[i] << ' ';
  if (l > 0) out << v[l - 1];
  return out;
}
template <typename T>
void trace(const char* name, T&& arg1) {
  cout << name << " : " << arg1 << endl;
}
template <typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1 << " | ";
  trace(comma + 1, args...);
}
long long int gcd(long long int a, long long int b) {
  if (b < a) {
    swap(a, b);
  }
  if (a == 0) {
    return b;
  }
  return gcd(b % a, a);
}
long long int lcm(long long int a, long long int b) {
  return (a * b / gcd(a, b));
}
long long int primefactorise(int n) {
  if (n == 1) {
    return 1;
  }
  long long int ans = n;
  while (n % 2 == 0) {
    n = n / 2;
    if (n != 1) {
      ans += n;
    }
  }
  for (int i = 3; i <= sqrt(n); i = i + 2) {
    while (n % i == 0) {
      n = n / i;
      if (n != 1) {
        ans += n;
      }
    }
  }
  ans += 1;
  return ans;
}
long long int power(long long int a, long long int b) {
  long long int ans = 1;
  while (b > 0) {
    if (b % 2 == 1) {
      ans *= a;
      ans = ans;
    }
    b /= 2;
    a *= a;
    a = a;
  }
  return ans;
}
vector<long long int> getbinary(long long int first, long long int size) {
  vector<long long int> bin(size, 0);
  long long int iter = 0;
  while (first > 0) {
    if (first % 2 == 0) {
      bin[iter] = 0;
    } else {
      bin[iter] = 1;
    }
    first /= 2;
    iter++;
  }
  return bin;
}
vector<long long int> getprimes() {
  vector<long long int> primes(1000000, 0);
  vector<long long int> ans;
  for (int i = 2; i < 1000000; i++) {
    if (primes[i] == 0) {
      for (int j = 2 * i; j < 1000000; j += i) {
        primes[j] = 1;
      }
      ans.push_back(i);
    }
  }
  return ans;
}
const long long int size = 10;
struct tnode {
  tnode* child[size];
  long long int isword;
};
tnode* makenode() {
  tnode* temp = new tnode;
  for (int i = 0; i < size; i++) {
    temp->child[i] = NULL;
  }
  temp->isword = 0;
  return temp;
}
void insert(tnode* root, string s) {
  tnode* temp = root;
  for (int i = 0; i < s.size(); i++) {
    long long int key = s[i] - 'a';
    if (temp->child[key] == NULL) {
      temp->child[key] = makenode();
    }
    temp = temp->child[key];
  }
  temp->isword = 1;
}
long long int search(tnode* root, string s) {
  tnode* temp = root;
  for (int i = 0; i < s.size(); i++) {
    long long int key = s[i] - 'a';
    if (temp->child[key] == NULL) {
      return 0;
    }
    temp = temp->child[key];
  }
  return temp->isword;
}
struct ConvexHullDynamic {
  static const long long int INF = 1e18;
  struct Line {
    long long int a, b;
    double xLeft;
    enum Type { line, maxQuery, minQuery } type;
    long long int val;
    explicit Line(long long int aa = 0, long long int bb = 0)
        : a(aa), b(bb), xLeft(-INF), type(Type::line), val(0) {}
    long long int valueAt(long long int first) const { return a * first + 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 int a, long long int 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 int getBest(long long int first) {
    Line q;
    q.val = first;
    q.type = isMax ? Line::Type::maxQuery : Line::Type::minQuery;
    auto bestLine = hull.lower_bound(q);
    if (isMax) --bestLine;
    return bestLine->valueAt(first);
  }
};
void solve() {
  long long int n;
  cin >> n;
  long long int a[n], c[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> c[i];
  }
  long long int dp[n];
  dp[0] = 0;
  ConvexHullDynamic dh(0);
  dh.addLine(c[0], dp[0]);
  for (int i = 1; i < n; i++) {
    dp[i] = dh.getBest(a[i]);
    dh.addLine(c[i], dp[i]);
  }
  cout << dp[n - 1] << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cout.precision(50);
  solve();
}
