Specialty of arrays

0

0 votes
Implementation, Basic Programming, Medium, Hash function, Basics of Implementation
Problem

You are given an array A of N elements. You are required to determine the specialty of the array that is defined as: 

Determine the Bitwise OR of the maximum and minimum elements of every subset of the size that are greater than or equal to 2 and add them. 

As the answer can be large, you must print it by taking modulo with 1000000007.

Input format

  • First line: N denoting the number of elements of the array
  • Second line: N space-separated integers denoting the elements of the array

Output format

For each query, you are required to print an integer denoting the specialty of the array.

Constraints

1N200000

1A[I]1000

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

Array contains 3 integers . Thus all subsets having size >= 2 are :- 

{ { 2, 5 } , { 2 , 5} , {5 , 5} , {2 , 5 , 5 } } , thus bitwise OR of the maximum and minimum elements of those subsets are

{ 7 , 7 , 5 , 7 } respectively , thus summation of all is 7 + 7 + 5 + 7 = 26%1000000007 = 26 .

Editor Image

?