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