ll@v[4],@n,a[4]{*v}; rep(i,n<400?n:n%4+400){ ll d=min(v[i+1&3]-a[i+1&3],a[i&3]); a[i+1&3]+=d; a[i&3]-=d; } wt(a(4));