import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Map<Long, List<Integer>> map = new HashMap<>();
        long[] nums = new long[n];
        for (int i = 0; i < n; i++) {
            nums[i] = sc.nextLong();
            if (!map.containsKey(nums[i])) map.put(nums[i], new ArrayList<>());
            map.get(nums[i]).add(i);
        }
        Queue<Integer> queue = new LinkedList<>();
        boolean[] visited = new boolean[n];
        queue.offer(0);
        visited[0] = true;
        int ans = 0;
        while (!queue.isEmpty()) {
            int size = queue.size();
            while (size-- > 0) {
                int x = queue.poll();
                if (x == n - 1) {
                    System.out.println(ans);
                    return;
                }
                if (!visited[x + 1]) {
                    visited[x + 1] = true;
                    queue.offer(x + 1);
                }
                if (map.containsKey(nums[x])) {
                    for (int i : map.get(nums[x])) {
                        if (!visited[i]) {
                            visited[i] = true;
                            queue.offer(i);
                        }
                    }
                    map.remove(nums[x]);
                }
            }
            ans++;
        }
        sc.close();
    }
}