;; D - Xor Sum 4

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

(defun main ()
  (let* ((N (read)))
    (print (solve N))
    (fresh-line)))

(defun solve (N)
  ; 各桁を集約
  (reduce #'(lambda (l h) (mod (+ l (ash h 1)) *modulus*))
    ; 2進各桁のXORの総和 (= 1の個数 * 0の個数)
    (map 'vector #'(lambda (m) (* m (- N m)))
      ; 各数を2進各桁のベクトルに変換し和 (2進各桁の1の個数) を求める
      (loop with vec = (to-bit-vector (read))
            repeat (1- N)
            do (map-into vec #'+ vec (to-bit-vector (read)))
            finally (return vec)))
    :from-end t))

(defun to-bit-vector (n)
  "整数nを2進各桁の配列 (最下位が前) に変換"
  (loop with vec = (make-array *max-bits*)
        for i from 0 below *max-bits*
        for m = n then (ash m -1) do (setf (aref vec i) (mod m 2))
        finally (return vec)))

(compile 'to-bit-vector)
(compile 'solve)

(main)
