Given an array I have to find the sum of all the bitwise OR of the maximum and the minimum element of all possible subset of the given array whose size is greater than or equal to 2.
Eg- [1,3,5]
Subset with size >=2 are {1,3}{1,5}{3,5}{1,3,5}

{1,3}-biwise OR of the max and min element in this subset=3

{1,5}-biwise OR of the max and min element in this subset=5

{3,5}-biwise OR of the max and min element in this subset=7

{1,3,5}-biwise OR of the max and min element in this subset=5

So total sum is 3+5+7+5=20.

I tried to make modifications with Sum of bitwise OR of all possible subsets of given set but unable to draw a logic.

Note: The size of the array is of order 10^5.