n = 9;
a=zeros(n);
a(1,1)=2;
for i=2:n-1
   a(i,i)=2;
   a(i-1,i)=-1;
   a(i+1,i)=-1;
end;
a(n,n)=2;
a
end