#include using namespace std; #define ALL(x) x.begin(),x.end() #define rep(i,n) for(int i=0;i<(n);i++) #define debug(v) cout<<#v<<":";for(auto x:v){cout<bool chmax(T &a,const T &b){if(abool chmin(T &a,const T &b){if(b ostream &operator<<(ostream &os,const pair&p){ os< ostream &operator<<(ostream &os,const vector&v){ for(int i=0;i<(int)v.size();i++) os< istream &operator>>(istream &is,pair&p){ is>>p.first>>p.second; return is; } template istream &operator>>(istream &is,vector&v){ for(T &x:v)is>>x; return is; } template struct LiChaoTree{ struct Line{ T a,b; Line(T a,T b):a(a),b(b){} T get(T x)const{return a*x+b;} bool over(const Line &b,const T &x){return get(x) xs; vector seg; int sz; LiChaoTree(const vector &x,T INF):xs(x){ sz=1; while(sz<(int)xs.size())sz<<=1; while((int)xs.size()=r) return ; else if(lc!=mc) update(x,2*k,l,m); else update(x,2*k+1,m,r); } // add ax+b void update(T a,T b){ Line l(a,b); update(l,1,0,sz); } // xs[k] T query(int k){ T x=xs[k]; k+=sz; T ret=seg[k].get(x); while(k>1){ k>>=1; chmin(ret,seg[k].get(x)); } return ret; } }; signed main(){ int n;cin>>n; vector a(n),x(n),y(n); cin>>a>>x>>y; vector dp(n+1,0); dp[0]=0; LiChaoTree seg(a,LINF); seg.update(-2*x[0],dp[0]+x[0]*x[0]+y[0]*y[0]); rep(i,n){ dp[i+1]=seg.query(i)+a[i]*a[i]; if(i