There are two integer arrays, singer[n] and length[n]. Each song is described as singer[i] and length[i]. The fun amount for a song is the product of its length and the total number of different singers heard in all prior songs plus the singer of the current song. The songs can be played in any order.
Arrange the songs to produce the maximum possible fun listening to the entire playlist. Return that maximum fun value.
Constraints
1 \le≤ n \le≤ 10 5
1 \le≤ singer[i] \le≤ 10 9
1 \le≤ length[i] \le≤ 10 9
Example - 1
Given n = 3, singer[i] = [1, 2, 2] and length[i] = [2, 3, 2], the optimal order is
the first song, 1*2 = 2.
the third song, 2 * 2 = 4.
the second song, 2 * 3 = 6.
The maximum fun possible is 2 + 4 +6 = 12.
Example - 2
Given n = 3, singer[i] = [1, 1, 2] and length[i] = [5, 4, 3]
It is optimal to listen to the second song, the third song, and finally, the first song (1 * 3) + (2 * 4) + (2 * 5) = 21
Return the maximum value of fun value.