use v5.18; # strict say state
use warnings;
use Memoize;

chomp (my $n = <STDIN>);
chomp (my @a = split / /, <STDIN>);
my (@b, @c);
for my $i (0..($n-1)) {
  $b = $a[$i];
  my $j = 0;
  while ($b) {
    $c[$j] += $b % 2;
    $b >>= 1;
    $j++;
  }
}
my $MOD = 1e9 + 7;
sub modpow {
  my ($a, $n) = @_;
  my $r = 1;
  while ($n > 0) {
    $r = $r * $a % $MOD if $n & 1;
    $a = $a * $a % $MOD;
    $n >>= 1;
  }
  return $r;
}
memoize('modpow');
my $ans = 0;
for my $i (0..@c-1) {
  my $b = modpow(2, $i);
  $b *= $c[$i];
  $b %= $MOD;
  $b *= $n - $c[$i];
  $b %= $MOD;
  $ans += $b;
  $ans %= $MOD;
}
say $ans;