clear all;
close all;

d=[350; 340; 450; 650; 650; 550; 700; 670; 350; 450; 400; 650];

cvx_begin
variables x(13) s(13) y(12) z(12);
minimize (50*sum(y)+50*sum(z)+20*sum(s))
subject to
x(2:13)+s(1:12)-s(2:13)==d;
x(2:13)-x(1:12)==y-z;
x(1)==0;
s(1)==0;
s(13)==0;
s>=0;
x>=0;
s>=0;
y>=0;
z>=0;
cvx_end