def run():
  b = 10**9+7
  bit = 60
  N = int(input())
  a_li = list(map(int, input().split()))
  ans = 0
  dp = [[0]*bit for i in range(N)]
  for i in range(bit):
    dp[0][i] = (a_li[0] >> i) & 1
  for i in range(1, N):
    tem = 0
    for j in range(bit):
      a_j = (a_li[i] >> j) & 1
      dp[i][j] = dp[i-1][j] + a_j
      if a_j == 1:
        tem += (i-dp[i-1][j]) << j
      else:
        tem += dp[i-1][j] << j
    #print(ans, tem)
    ans += tem
  #print(dp)
  print(ans%b)

if __name__ == '__main__':
  run()