```
class Solution(object):
def singleNonDuplicate(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
if nums[0] != nums[1]:
return nums[0]
elif nums[-1] != nums[-2]:
return nums[-1]
for i in range(1, (len(nums)-1)):
if (nums[i] != nums[i+1]) and (nums[i] != nums[i-1]):
return nums[i]
```