added code to compute array gain against the average gain of each element