(defun read-list-from-string (str)
  (read-from-string (concatenate 'string "(" str ")")))

(defun read-list (&optional (stream *standard-input*))
  (read-list-from-string (read-line stream)))

(defun map-pair (f list)
  (labels ((inner-loop (head rest acc)
	     (if rest
		 (inner-loop (car rest) (cdr rest) (+ (reduce #'+ (mapcar (lambda (x) (funcall f head x)) rest)) acc))
		 acc)))
    (inner-loop (car list) (cdr list) 0)))

(defun solve (l1 l2)
  (* (map-pair (lambda (x y) (abs (- x y))) l1)
     (map-pair (lambda (x y) (abs (- x y))) l2)))

(defun test-case ()  
  (loop repeat (expt 10 5) collect (- (random (* 2 (expt 10 9))) (expt 10 9))))
(setf test (test-case))
(setf test2 (test-case))


(let ((size (read-list))
      (l1 (read-list))
      (l2 (read-list)))
  (format t "~D~%" (mod (solve l1 l2) (+ 7 (expt 10 9)))))
