input: def closest_num(arr: List[int], num: int) -> int:
      """
      Find the closest number to the given number in the array.
      >>> closest_num([5, 4, 8, 7], 5)
      5
      >>> closest_num([1, 2, 3, 4, 6], 5)
      4
      """
output:     closest = arr[0]
      for n in arr:
          if abs(n - num) < abs(closest - num):
              closest = n
      return closest