def adjustOrd(sizes): ''' adjust the chain-multiply of matrix, sizes=[row1,row2,..,rown,coln]''' n = len(sizes) if n<3: return