#ifdef LOCAL111
	#define _GLIBCXX_DEBUG
#else
	#define NDEBUG
#endif
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
const long long INF = 1e15;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { os << '(' << p.first << ' ' << p.second << ')'; return os; }

// #define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);
}

class ConvexHullTrick {
public:
	using T = long long;
	using P = pair<T, T>;
	vector<P> lines;

	ConvexHullTrick() {
		// lines.emplace_back(0, 0);
	}

	bool check(P l1, P l2, P l3) {
		if(l1 < l3) swap(l1, l3);
		return (l3.second - l2.second) * (l2.first - l1.first) 
			>= (l2.second - l1.second) * (l3.first - l2.first);	
	}

	void add(T a, T b) {
		P line(a, b);
		while(lines.size() >= 2 and check(*(lines.end()-2), lines.back(), line)) {
			lines.pop_back();
		}
		lines.emplace_back(line);
	}


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


	T query(T x) {
		assert(lines.size() != 0);
		
		if(lines.size() == 1) {
			return calc(0, x);
		}

		int ng = 0, ok = lines.size();
		
		auto check = [&](int i) -> bool {
			if(i+1 == lines.size()) {
				return true;
			}
			return calc(i, x) < calc(i+1, x);
		};

		if(check(ng)) {
			return calc(ng, x);
		}


		while(ok-ng > 1) {
			int m = (ok+ng)/2;
			if(check(m)) {
				ok = m;
			} else {
				ng = m;
			}
		}
		return calc(ok, x);

	}
};

int main()
{
	ios_init();
	
	int n;
	
	while(cin >> n) {
		vector<LL> a(n);
		vector<LL> x(n);
		vector<LL> y(n);
		REP(i, n) cin >> a[i];
		REP(i, n) cin >> x[i];
		REP(i, n) cin >> y[i];


		ConvexHullTrick cht;

		vector<LL> dp(n+1, INF);
		dp[0] = 0;
		REP(i, n) {
			// REP(k, i+1) {
			// 	chmin(dp[i+1], dp[k] + (a[i]-x[k])*(a[i]-x[k]) + y[k]*y[k]);
			// }
			cht.add(x[i], dp[i] + x[i] * x[i] + y[i] * y[i]);
			dp[i+1] = cht.query(-2*a[i]) + a[i] * a[i];
		}

		dpite(ALL(dp));

		cout << dp[n] << endl;
	}

	return 0;
}