Write a python function that takes an integer array as input and returns the gcd of the smallest and the largest element in the array. Note: The largest integer that divides both of two integers is called the greatest common divisor(gcd) of these integers.