;; D - Xor Sum 4

(defparameter *modulus* (+ (expt 10 9) 7))
(defparameter *max-bits* 60)

(defun main ()
  (let* ((N (read))
         (A (loop repeat N collect (read))))
    (print (solve N A))
    (fresh-line)))

(defun solve (N A)
  ; 各桁を集約
  (reduce #'(lambda (l h) (mod (+ l (ash h 1)) *modulus*))
    ; 2進各桁のXORの総和 (= 1の個数 * 0の個数)
    (mapcar #'(lambda (m) (* m (- N m)))
      ; ベクトル和 (2進各桁の1の個数)
      (reduce #'(lambda (l1 l2) (mapcar #'+ l1 l2))
        ; 各数を2進各桁のリスト (最下位が前) に変換
        (mapcar #'to-binary-list A)))
    :from-end t))

(defun to-binary-list (n)
  "整数nを2進各桁のリスト (最下位が前) に変換"
  (loop repeat *max-bits*
        for m = n then (ash m -1) collect (mod m 2)))

(compile 'to-binary-list)
(compile 'solve)

(main)
