Vasya has an array of integers of length *n*.

Vasya performs the following operations on the array: on each step he finds the longest segment of consecutive equal integers (the leftmost, if there are several such segments) and removes it. For example, if Vasya's array is [13, 13, 7, 7, 7, 2, 2, 2], then after one operation it becomes [13, 13, 2, 2, 2].

Compute the number of operations Vasya should make until the array becomes empty, i.e. Vasya removes all elements from it.
The first line contains a single integer *n* (1 ≤ *n* ≤ 200 000) — the length of the array.

The second line contains a sequence *a*<sub class="lower-index">1</sub>, *a*<sub class="lower-index">2</sub>, ..., *a*<sub class="lower-index">*n*</sub> (1 ≤ *a*<sub class="lower-index">*i*</sub> ≤ 10<sup class="upper-index">9</sup>) — Vasya's array.
In the first example, at first Vasya removes two fives at the second and third positions. The array becomes [2, 2]. In the second operation Vasya removes two twos at the first and second positions. After that the array becomes empty.

In the second example Vasya has to perform five operations to make the array empty. In each of them he removes the first element from the array.

In the third example Vasya needs three operations. In the first operation he removes all integers 4, in the second — all integers 100, in the third — all integers 2.

In the fourth example in the first operation Vasya removes the first two integers 10. After that the array becomes [50, 10, 50, 50]. Then in the second operation Vasya removes the two rightmost integers 50, so that the array becomes [50, 10]. In the third operation he removes the remaining 50, and the array becomes [10] after that. In the last, fourth operation he removes the only remaining 10. The array is empty after that.
4
2 5 5 2
2
5
6 3 4 1 5
5
8
4 4 4 2 2 100 100 100
3
6
10 10 50 10 50 50
4
1
1
1
100
45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45 45
1
1
100
1
2
1 100
2
2
1 1
1
2
100 100
1
3
1 1 1
1
3
1 1 3
2
3
1 100 1
3
3
1 5 6
3
3
10 4 10
3
3
10 10 4
2
4
100 4 56 33
4
4
1 2 2 1
2
4
1 1 1 3
2
4
5 1 1 1
2
1
4
1
2
21 21
1
3
48 48 14
2
10
69 69 69 69 69 13 69 7 69 7
6
20
15 15 71 100 71 71 15 93 15 100 100 71 100 100 100 15 100 100 71 15
14
31
17 17 17 17 29 17 17 29 91 17 29 17 91 17 29 17 17 17 29 17 17 17 17 17 17 17 17 29 29 17 17
12
43
40 69 69 77 9 10 58 69 23 9 58 51 10 69 10 89 77 77 9 9 10 9 69 58 40 10 23 10 58 9 9 77 58 9 77 10 58 58 40 77 9 89 40
38
54
34 75 90 23 47 13 68 37 14 39 48 41 42 100 19 43 68 47 13 47 48 65 45 89 56 86 67 52 87 81 86 63 44 9 89 21 86 89 20 43 43 37 24 43 77 14 43 42 99 92 49 99 27 40
53
66
79 79 49 49 79 81 79 79 79 79 81 49 49 79 49 49 79 49 49 81 81 49 49 49 81 49 49 49 81 81 79 81 49 81 49 79 81 49 79 79 81 49 79 79 81 49 49 79 79 79 81 79 49 47 49 49 47 81 79 49 79 79 79 49 49 49
34
80
80 86 39 5 58 20 66 61 32 75 93 20 57 20 20 61 45 17 86 43 31 75 37 80 92 10 6 18 21 8 93 92 11 75 86 39 53 27 45 77 20 20 1 80 66 13 11 51 58 11 31 51 73 93 15 88 6 32 99 6 39 87 6 39 6 80 8 45 46 45 23 53 23 58 24 53 28 46 87 68
78
100
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
3
9
1 2 2 2 1 2 2 2 1
3
12
1 1 1 49 63 63 63 19 38 38 65 27
7
7
31 31 21 21 13 96 96
4
3
1000000000 1 1000000000
3
from math import log10, floor

n = int(input())

sequence = list(map(int,input().split()))

def insert(num,lst):
	l, r = 0, len(lst) - 1
	if lst[l] < num:
		lst.insert(0,num)
	if lst[r] > num:
		lst.insert(len(lst),num)
	while r-l > 1:
		mid = (l+r)//2
		if lst[mid] > num:
			r = mid
		else:
			l = mid
	lst.insert(r,num)

class Node:
	def __init__(self, count, groupid, num):
		self.num = num
		self.count = count
		self.next = None
		self.prev = None
		self.groupid = groupid
		self.tuple = (count, -groupid)
		self.delete = False
	def __lt__(self, other):
		return self.tuple < other.tuple
	def __gt__(self, other):
		return self.tuple > other.tuple
	def __str__(self):
		return str((self.count,self.groupid,self.num))

def sizing(seq):
	count = 1
	current = seq[0]
	groupid = 0
	seq_with_size = []
	for num in seq[1:]:
		if num != current:
			node = Node(count,groupid,current)
			if seq_with_size:
				seq_with_size[-1].next = node
				node.prev = seq_with_size[-1]
			seq_with_size.append(node)
			groupid += 1;
			count = 0
			current = num
		count += 1
	node = Node(count,groupid,current)
	seq_with_size[-1].next = node
	node.prev = seq_with_size[-1]
	seq_with_size.append(node)
	return seq_with_size

sequence_with_size = sizing(sequence)

sortseq = sorted(sequence_with_size,key = lambda x: x.tuple)[::-1]

res = 0
while sortseq:
	s0 = sortseq[0]
	if s0.delete:
		del sortseq[0]
		continue
	prev = s0.prev
	nxt = s0.next
	if prev and nxt:
		if prev.num == nxt.num:
			next_of_next = nxt.next
			prev_of_prev = prev.prev
			newnum = prev.num
			newcount = prev.count + nxt.count
			newgroupid = (prev.groupid + nxt.groupid) / 2
			node = Node(newcount, newgroupid, newnum)
			node.prev = prev_of_prev
			node.next = next_of_next

			insert(node,sortseq)

			if next_of_next:
				next_of_next.prev = node
			if prev_of_prev:
				prev_of_prev.next = node
			prev.delete = True
			nxt.delete = True
		else:
			prev.next = nxt
			nxt.prev = prev
	elif prev:
		prev.next = None
	elif nxt:
		nxt.prev = None
	del sortseq[0]
