A product formula for the parity generating function of the number of 1’s in invertible matrices over Z 2 is given. The computation is based on algebraic tools such as the Bruhat decomposition. It is somewhat surprising that the number of such matrices with odd number of 1’s is greater than the number of those with even number of 1’s. The same technique can be used to obtain a parity generating function also for symplectic matrices over Z 2 . We present also a generating function for the sum of entries of matrices over an arbitrary finite field F q calculated in F q . The Mahonian distribution appears in these formulas.