class FirstRepeat:
    def findFirstRepeat(self, A, n):
        # write code here
        hash = {}
        for i in range(n):
            if hash.has_key(A[i]):
                return A[i]
            hash[A[i]] = i