Store frequency of all possible sums of first two elements
let temp = a [ i ] + a [ j ] ; if ( temp < sum ) if ( m . has ( temp ) ) m . set ( temp , m . get ( temp ) + 1 ) ; else m . set ( temp , 1 ) ; } }