다음 코드는 N 개의 원소 중 서로 다른 값의 개수를 출력한다. 결과는 옳지만 N 이 커지면 시간 초과가 난다. 같은 결과를 시간 제한 안에서 출력하라.
n = int(input())
arr = list(map(int, input().split()))
unique = []
for x in arr:
found = False
for y in unique:
if x == y:
found = True
break
if not found:
unique.append(x)
print(len(unique))
1 ≤ N ≤ 10^5, 0 ≤ Ai ≤ 10^9
5 1 2 3 4 5
5
5 1 1 1 1 1
1
6 1 2 1 3 2 1
3