n = int(input())
a = list(map(int, input().split()))
state = None
cnt = 1
for i in range(1, n):
    if state == None:
        if a[i] > a[i - 1]:
            state = 'up'
        elif a[i] < a[i - 1]:
            state = 'down'
        else:
            continue
    elif state == 'up' and a[i] < a[i - 1]:
        cnt += 1
        state = None
    elif state == 'down' and a[i] > a[i - 1]:
        cnt += 1
        state = None
print(cnt)

2ea952b80df8b60ff89f67b5241918f8c5f4897e
<mask token>

<mask token>
for i in range(1, n):
    if state == None:
        if a[i] > a[i - 1]:
            state = 'up'
        elif a[i] < a[i - 1]:
            state = 'down'
        else:
            continue
    elif state == 'up' and a[i] < a[i - 1]:
        cnt += 1
        state = None
    elif state == 'down' and a[i] > a[i - 1]:
        cnt += 1
        state = None
print(cnt)

n = int(input())
a = list(map(int, input().split()))
state = None
cnt = 1
for i in range(1, n):
    if state == None:
        if a[i] > a[i - 1]:
            state = 'up'
        elif a[i] < a[i - 1]:
            state = 'down'
        else:
            continue
    elif state == 'up' and a[i] < a[i - 1]:
        cnt += 1
        state = None
    elif state == 'down' and a[i] > a[i - 1]:
        cnt += 1
        state = None
print(cnt)
