∵ Sum of all entries of matrix A must be prime p such that 2<p<8, then sum of entries may be 3,5 or 7.
If sum is 3, then possible entries are (0,0,0,3), (0,0,1,2) or (0,1,1,1).
∴ Total number of matrices =4+12+4=20
If sum is 5, then possible entries are
(0,0,0,5),(0,0,1,4),(0,0,2,3),(0,1,1,3), (0,1,2,2) and (1,1,1,2).
Total number of matrices =4+12+12+12+12+4=56
If sum is 7, then possible entries are
(0,0,2,5),(0,0,3,4),(0,1,1,5),(0,3,3,1),(0,2,2,3),(1,1,1,4),(1,2,2,2),(1,1,2,3) and (0,1,2,4)
Total number of matrices =12+12+12+12+12+4+4+12+24=104
∴ Total number of required matrices
=20+56+104
=180