#C1847. Unique Color Index Finder

    ID: 45097 Type: Default 1000ms 256MiB

Unique Color Index Finder

Unique Color Index Finder

You are given a list of colors represented by integers. Each color may appear more than once. Your task is to find the smallest index of a color that appears exactly once in the list. If multiple colors appear only once, choose the one with the smallest index. If no color appears only once, output (-1).

Formally, given an array (a_0, a_1, \dots, a_{n-1}), determine the smallest index (i) such that the frequency of (a_i) is 1. If there is no such index, print (-1).

inputFormat

The input is read from standard input. The first line contains an integer (n) representing the number of colors. The second line contains (n) space-separated integers denoting the colors.

outputFormat

Output a single integer to standard output: the smallest index of a unique color if it exists, otherwise (-1).## sample

1
1
0