A=zeros(n);
A(1,1)=1;
A(1,2)=-1;
for i=2:n-1
    A(i,i+1)=i;
    A(i,i-1)=i-1;
    A(i,i)=-(2*i-1);
end
A(n,n)=1;
A