use v5.18; # strict say state
use warnings;
use List::Util qw(reduce first max min sum0);

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++;
  }
}
@c = map {($n-$_)*$_} @c;
my $ans = 0;
for my $i (0..@c-1) {
  $ans += 2 ** ($i) * $c[$i];
  $ans %= 1e9+7;
}
say $ans;