Maximize with matrices

How do I use maximise with an arbitrary sized symbolic matrix?

e.g for a small matrix it is fine to write it out,

ymatrix = {{y11, y12, y13}, {y21, y22, y23}, {y31, y32, y33}}

NMaximize[-2*(Total[Total[ymatrix]])^2 - 3 Total[Total[ymatrix]] + 5, {y11, y12, y13, y21, y22, y23, y31, y32, y33}]


But how would I do this if ymatrix bigger, for example is of dimensions {100,3}

ymat = Array[y, {10, 3}];