Implement a function to find the first repeating element in an array.
Return the element whose first occurrence has the smallest index among all repeated values. Return -1 if every element is unique.
Input: a list of integers. Output: an integer.
Examples: [10, 5, 3, 4, 3, 5, 6] returns 5; [1, 2, 3, 4] returns -1.
Constraints: the array contains 1 to 1,000 integers, and values may be negative.
def first_repeating_element(nums):