program sum_of_gcd_of_tuples
  implicit none
  integer :: k, i, j
  integer(8) :: x(200) = 0, y(200) = 0
  read(*,*) k
  do i = k, 1, -1
    x(i) = (k / i) ** 3
    do j = 2 * i, k, i
      x(i) = x(i) - x(j)
    end do
    y(i) = i
  end do
  write(*,'(i0)') dot_product(x, y)
end program sum_of_gcd_of_tuples