#include using namespace std; using Int = long long; template inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template inline void chmax(T1 &a,T2 b){if(a>n; vector a(n),x(n),y(n); for(Int i=0;i>a[i]; for(Int i=0;i>x[i]; for(Int i=0;i>y[i]; auto tri=[](Int x){x=abs(x);return x*x*x;}; const Int INF = 1e18; vector dp(n+1,INF); random_device rd; mt19937 mt(rd()); dp[0]=0; for(Int i=0;i(i,300);j++){ Int k=i-j; chmin(dp[i+1],dp[k]+tri(x[k]-a[i])+tri(y[k])); k=j; chmin(dp[i+1],dp[k]+tri(x[k]-a[i])+tri(y[k])); k=mt()%(i+1); chmin(dp[i+1],dp[k]+tri(x[k]-a[i])+tri(y[k])); } } cout<