If i'm correct you are trying to get the distance from each node in the network to each other node, correct?
(SELECT array_agg(id) FROM ma_2po_4pgr ) returns each unique edge in the network, while'you want this query to return each unique node. To get all the unique nodes you have to select them form the
target columns. You can do this via
SELECT DISTINCT((SELECT DISTINCT source FROM ma_2po_4pgr) UNION (SELECT DISTINCT target FROM ma_2po_4pgr))
You have 41000 ID's, but this does not mean that you expect 41000**2 results, as this table is an edge table, not a node table. One node might be connected to multiple edges. You would expect the amount equal to
COUNT('subquery with the union from previous paragraph') squared. In other words, from each node to each other node.
So your total query will be like this (not tested):
SELECT * FROM pgr_dijkstraCostMatrix(
'SELECT id, source, target, cost, reverse_cost FROM ma_2po_4pgr',
(SELECT array_agg(distinct nodes.id) from
(SELECT DISTINCT source as id FROM ma_2po_4pgr)
(SELECT DISTINCT target as id FROM ma_2po_4pgr)
) as nodes