main = do a <- readLn :: IO Int putStrLn . show $ fn a fn n | n < 15 = -1 | otherwise = head [y | y <- [8..], n `div` y == 1, n `mod` y == 7]