;; D - Xor Sum 4

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

(defun add-bits-to-vector (n vec)
  "配列vecに整数nの2進各桁を加える"
  (declare (optimize (speed 3) (safety 0) (debug 0)))
  (loop for m = n then (ash m -1) until (zerop m)
        for i from 0
        do (incf (aref vec i) (logand m 1))))

(defun solve (N)
  (let ((vec (make-array *max-bits* :initial-element 0)))
    ; 各数を2進数に変換したときの各桁の1の個数を求める
    (loop repeat N do (add-bits-to-vector (read) vec))
    ; 各桁を集約
    (reduce #'(lambda (l h) (mod (+ l (ash h 1)) *modulus*))
      ; 2進各桁のXORの総和 (= 1の個数 * 0の個数)
      (map 'vector #'(lambda (m) (* m (- N m))) vec)
      :from-end t)))

(defun main ()
  (print (solve (read)))
  (fresh-line))

(main)
