program main
integer :: n,gcd=0,ans = 0
read(*,*)n
do i = 1,n
do j = 1,n
do k = 1,n
do l = 1,n
if (mod(i,l)==0 .and. mod(j,l)==0 .and. mod(k,l)==0) gcd = max(gcd,l)
end do
ans = ans + gcd
end do
end do
end do
write(*,*)ans
end program main