# Matlab, <s>60</s> 54 bytes This would be Matlab's special field *IF* we could use builtin functions... Thanks @sanchises for fixing the error I missed. c=0;a=input('');for A=a;v=c+1:c+A;d(v,v)=1;c=c+A;end;d