#include <stdio.h>
#include <string.h>

int xor (int, int);
int main()
{
    int a[300000];
    int n,i,j,sum=0;

    scanf("%d", &n);
    for (i = 0; i < n; i++)
    {
        scanf("%d" ,&a[i]);
    }
    for (i = 0; i < n-1;i++){
        for (j = i + 1; j < n;j++){
            sum += xor(a[i], a[j]);
        }
    }
        printf("%d\n", sum/(1000000007));

    return 0;
}

int xor (int a, int b) {
    int x = 0, y = 0, i, j, t = 2, c, d,sum = 0;

    while(1)
    {
        c = a % t;
        d = b % t;
        if(c!=d)
        {
            sum += t / 2;
        }
        a -= c;
        b -= d;
        t = t * 2;
        if(0==a||0==b)
        {
            sum = sum + a + b;
            break;
        }
    }
    return sum;
}