#include<bits/stdc++.h>

#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/2;
const ll MOD = 1e9+7;
const double EPS=1e-12;

template<typename T>
class ConvexHullTrick {
private:
    vector<pair<T, T>> lines;
    int head;
    bool check(pair<T, T> l1, pair<T, T> l2, pair<T, T> l3) {
        return (l3.second - l2.second) * (l2.first - l1.first) >= (l2.second - l1.second) * (l3.first - l2.first);
    }

    T f(int i, T x) {
        return lines[i].first * x + lines[i].second;
    }


public:
    ConvexHullTrick():head(0){}

    bool empty(){
        return lines.size()-head==0;
    }

    void insert(T a, T b) {
        pair<T, T> line(a, b);
        if(lines.size()-head>=1&&a==lines.back().first&&b>lines.back().second)return;
        while (lines.size()-head >= 2 && check(*(lines.end() - 2), lines.back(), line))
            lines.pop_back();
        lines.emplace_back(line);
    }
    T getmin(T x) {
        while (lines.size() - head >= 2 && (f(head, x)>=f(head + 1, x)))
            ++head;
        return f(head, x);
    }
};
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;cin>>N;
  ll a[N];
  for(ll i=0;i<N;i++)cin>>a[i];
  ll x[N];
  for(ll i=0;i<N;i++)cin>>x[i];
  ll y[N];
  for(ll i=0;i<N;i++)cin>>y[i];
  ConvexHullTrick<ll> cht;
  ll dp=0;
  for(ll i=0;i<N;i++){
    cht.insert(-2*x[i],x[i]*x[i]+y[i]*y[i]+dp);
    dp=cht.getmin(a[i])+a[i]*a[i];
  }
  cout<<dp<<endl;
  return 0;
}