Determines whether key appears exactly twice in the array a.