import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  k <- unsafeTextToInt <$> T.getLine :: IO Int
  let
    interval = [1..k] :: [Int]
    gcds :: [Int]
    gcds = do
      a <- interval
      b <- interval
      let ab = gcd a b
      c <- interval
      return $ gcd ab c
  print . sum $ gcds

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n
