import cmath
import sys

INF=10**18
MOD=10**9+7
MAX=10**5+7


def main():
    N=int(input())
    a=list(map(int, input().split()))

    ans=0
    for b in range(60):
        c0=0
        c1=0
        for i in range(N):
            if a[i] & (1<<b):
                c1+=1
            else:
                c0+=1

        ans+=(1<<b)*c0*c1

    print(ans)


if __name__=='__main__':
    main()