#include <iostream>
                                    #include <iomanip>
                                    #include <sstream>
                                    #include <cstring>
                                    #include <vector>
                                    #include <deque>
                                    #include <queue>
                                    #include <set>
                                    #include <map>
                                    #include <valarray>
                                    #include <iterator>
                                    #include <functional>
                                    #include <limits>
                                    #include <algorithm>
                                    #include <numeric>
                                    #include <cmath>
                                    #include <cassert>
                                    #include <unordered_map>
                                    #include <unordered_set>
                                    #include <stack>
                                    using namespace std;
                                    #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
                                     #define trace(x) cerr << #x << ": " << x << " " << endl;
                                 
                                    typedef int64_t ll;
                                 
                                    #define endl '\n'
                                    #define int ll
                                    ll mod=1e9+7;
                                    ll mod1=1e9+5;
                                    
                                    ll power(ll a,ll b)
                                    {
                                        if(b==0) return 1;
                                        else if(b%2==0)
                                            return power((((a%mod)*(a%mod))%mod),b/2)%mod;
                                        else return ((a%mod)*(power((((a%mod)*(a%mod))%mod),b/2)%mod))%mod;
                                    }
                                     int sum(int arr[], int n) 
                                { 
                                    int sum = 0; 
                                    for (int i = 0; i < 60; i++)  
                                    { 
                                        //  Count of zeros and ones 
                                        int zc = 0, oc = 0;  
                                          
                                        // Individual sum at each bit position 
                                         int idsum = 0;  
                                        for (int j = 0; j < n; j++) 
                                        { 
                                            if (arr[j] % 2 == 0) 
                                                zc++; 
                                            else
                                                oc++; 
                                            arr[j] /= 2; 
                                        } 
                                          
                                        // calculating individual bit sum
                                        idsum=oc;
                                        idsum*=zc;
                                        idsum%=mod;
                                        idsum*=power(2,i);

                                        
                                        idsum%=mod;  
                                  
                                        // final sum     
                                        sum += idsum;  
                                        sum%=mod;
                                    } 
                                    return sum; 
                                } 
                                  
                                
                                    
                                int32_t main()
                                {
                                    IOS
                                   
                                
                                int n;
                                cin>>n;
                                int a[n];for(int i=0;i<n;++i)
                                cin>>a[i];
                                cout<<sum(a,n);

                                }                       


Measured memory_bytes: 2560