CodeEff/ECCO huggingface dataset:
# Original solution

def sign(x):
    return (x > 0) - (x < 0)


def main():
    _ = int(eval(input()))
    a = list(map(int, input().split()))
    ans = []
    arr = []
    for an in a:
        if len(arr) < 2:
            arr.append(an)
        else:
            state = sum([el - arr[i] for i, el in enumerate(arr[1:])])
            if state == 0:
                arr.append(an)
            else:
                current = an - arr[-1]
                if current == 0 or sign(state) == sign(current):
                    arr.append(an)
                else:
                    ans.append(arr)
                    arr = [an]
    ans.append(arr)

    print((len(ans)))


if __name__ == '__main__':
    main()


# Optimized solution

def sign(x):
    return (x > 0) - (x < 0)


def main():
    _ = int(eval(input()))
    a = list(map(int, input().split()))
    ans = []
    arr = []
    state = 0
    for an in a:
        if len(arr) < 2:
            arr.append(an)
        else:
            state += (arr[-1] - arr[-2])
            if state == 0:
                arr.append(an)
            else:
                current = an - arr[-1]
                if current == 0 or sign(state) == sign(current):
                    arr.append(an)
                else:
                    ans.append(arr)
                    arr = [an]
                    state = 0
    ans.append(arr)

    print((len(ans)))


if __name__ == '__main__':
    main()
# Original solution
n=int(eval(input()))
a=list(map(int, input().split()))
ans,c,d=0,1,True
while c<n:
    if a[c]==a[c-1]:
        c+=1
        continue
    if d:
        f=a[c]>a[c-1]
        d=False
    elif f:
        if a[c]<a[c-1]:
            ans+=1
            d=True
    else:
        if a[c]>a[c-1]:
            ans+=1
            d=True
    c+=1
print((ans+1))

# Optimized solution
n=int(eval(input()))
a=list(map(int, input().split()))
ans=1
d=0
for i in range(1,n):
    diff=a[i]-a[i-1]
    if d==0:
        d=diff
    elif d*diff<0:
        d=0
        ans+=1
print(ans)
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))

First = True
ans = 1
status = None
for i in range(1, N):
    if First:
        if A[i-1] < A[i]:
            status = "up"
            First = False
            continue
        elif A[i-1] > A[i]:
            status = "down"
            First = False
            continue

    if (status == "up") & (A[i-1] > A[i]):
        ans += 1
        First = True
        continue

    if (status == "down") & (A[i-1] < A[i]):
        ans += 1
        First = True
        continue

print(ans)






# Optimized solution
N = int(eval(input()))
A = list(map(int, input().split()))

ans = 1
status = "Unset"
for i in range(1, N):
    if status == "Unset":
        if A[i-1] < A[i]:
            status = "UP"
        elif A[i-1] > A[i]:
            status = "DOWN"

    else:
        if status == "UP" and A[i-1] > A[i]:
            ans += 1
            status = "Unset"

        if status == "DOWN" and A[i-1] < A[i]:
            ans += 1
            status = "Unset"

print(ans)
# Original solution
# AGC013A - Sorted Arrays
def main():
    n = int(eval(input()))
    A = tuple(map(int, input().rstrip().split()))

    # compress continuous parts of same numbers (e.g. 111 -> 1)
    B, cur = [], 0
    for i in A:
        if i != cur:
            B += [i]
            cur = i
    B += [0]

    # check the modified sequence
    ans, cur = 0, B[0]
    flg = B[0] < B[1]  # increasing (1) / decreasing (0)
    for i, j in enumerate(B[1:-1], start=1):
        if (flg and j < cur) or (not flg and j > cur):
            ans += 1
            flg = B[i] < B[i + 1]
        cur = j
    print((ans + 1))


if __name__ == "__main__":
    main()

# Optimized solution
# AGC013A - Sorted Arrays
def main():
    n = int(eval(input()))
    A = tuple(map(int, input().split()))
    ans, cur = 0, A[0]
    flg = 0  # unknown (0), increasing (1), decreasing (2)
    for i in A:
        if (flg == 1 and i < cur) or (flg == 2 and i > cur):  # end of trend
            ans += 1
            flg = 0
        elif not flg and cur < i:  # new increasing trend
            flg = 1
        elif not flg and cur > i:  # new decreasing trend
            flg = 2
        cur = i
    print((ans + 1))


if __name__ == "__main__":
    main()
# Original solution
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N,*A = list(map(int,read().split()))

# まず、重複を除外
B = [A[0]] + [y for x,y in zip(A,A[1:]) if x != y]

seq = []
answer = 0
for x in B:
    if not seq:
        answer += 1
        seq.append(x)
        continue
    if len(seq) == 1:
        seq.append(x)
        continue
    a,b = seq[-2:]
    if a < b < x or a > b > x:
        seq.append(x)
        continue
    # xを追加すると破綻
    answer += 1
    seq = [x]

print(answer)

# Optimized solution
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, *A = list(map(int, read().split()))

# 減少中、増大中であるようなときの数列の個数のmin
dp = 1, 1
for i in range(1, N):
    if A[i] > A[i-1]:
        dp = min(dp)+1, min(dp[0]+1, dp[1])
    elif A[i] == A[i-1]:
        pass
    else:
        dp = min(dp[0], dp[1]+1), min(dp)+1

print((min(dp)))
# Original solution
def main():
    n, *a = list(map(int, open(0).read().split()))

    c = 1
    f = 0
    d = {True: 1, False: -1}
    for i, j in zip(a, a[1:]):
      if i == j:
        continue
      else:
        g = d[i < j]
        if f * g == -1:
          f = 0
          c += 1
        else:
          f = g
    
    print(c)


if __name__ == '__main__':
    main()


# Optimized solution
def main():
    n, *a = list(map(int, open(0).read().split()))

    c = 1
    f = 0
    d = [-1,1]
    for i, j in zip(a, a[1:]):
      if i == j:
        continue
      else:
        g = d[i < j]
        if f * g == -1:
          f = 0
          c += 1
        else:
          f = g
    
    print(c)


if __name__ == '__main__':
    main()
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))

if N == 1:
    print((1))
elif N == 2:
    print((1))
else:
    cnt = 0
    for i in range(N - 1):
        if A[i] == A[i + 1]:
            A[i] = 0
            cnt += 1

    for _ in range(cnt):
        A.remove(0)
    #print(A)

    i = 1
    ans = 1
    n = len(A)
    while i < n - 1:
        if A[i-1] < A[i] < A[i+1] or A[i-1] > A[i] > A[i+1]:
            pass
        else:
            i += 1
            ans += 1
        i += 1
    print(ans)



# Optimized solution
N = int(eval(input()))
B = list(map(int, input().split()))

if N == 1:
    print((1))
elif N == 2:
    print((1))
else:
    A = [B[0]]
    cnt = 0
    for i in range(N - 1):
        if B[i] == B[i + 1]:
            pass
        else:
            A.append(B[i+1])

    i = 1
    ans = 1
    n = len(A)
    while i < n - 1:
        if A[i-1] < A[i] < A[i+1] or A[i-1] > A[i] > A[i+1]:
            pass
        else:
            i += 1
            ans += 1
        i += 1
    print(ans)
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))
cnt = 1
i = -1
flg = True
while True:
  i += 1
  if i >= n-1:
    break
  if a[i] < a[i+1]:
    flg = True
  elif a[i] > a[i+1]:
    flg = False
  else:
    continue
  for k in range(i, n-1):
    if (flg and a[k] > a[k+1]) or ((not flg) and a[k] < a[k+1]):
      cnt += 1
      i = k
      break
print(cnt)

# Optimized solution
n = int(eval(input()))
a = list(map(int, input().split()))
cnt = 1
b = [0] + a
c = [(i-j)//abs(i-j) for i, j in zip(a, b) if i != j]
del c[0]
if c:
  mae=c[0]
  d=iter(c)
  for x in d:
    if x != mae:
      cnt += 1
      try:
        mae = d.__next__()
      except StopIteration:
        break
print(cnt)
# Original solution
n=int(eval(input()))
a=list(map(int,input().split()))
b=0
ans=1
for i in range(n-1):
  if b==0 and a[i]!=a[i+1]:b=(a[i]<a[i+1])-(a[i]>a[i+1])
  elif a[i]<a[i+1] and b==-1:
    ans+=1
    b=0
  elif a[i]>a[i+1] and b==1:
    ans+=1
    b=0
print(ans)

# Optimized solution
n=int(eval(input()))
a=list(map(int,input().split()))
b=0
ans=1
for i in range(n-1):
  if b==0 and a[i]!=a[i+1]:
    if a[i]<a[i+1]:b=1
    else:b=-1
  elif(a[i]<a[i+1] and b==-1)or(a[i]>a[i+1] and b==1):
    ans+=1
    b=0
print(ans)
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))

count = 0
sign = 0
num = 0
ans = 0
for i, ai in enumerate(a):
    if count == 0:
        num = ai
        sign = 0
        count += 1
    elif count == 1:
        if ai > num:
            sign = 1
        elif ai < num:
            sign = -1
        else:
            sign = 0
        count += 1
        num = ai
    else:
        if sign == 0:
            if ai > num:
                sign = 1
            elif ai < num:
                sign = -1
            else:
                sign = 0
            count += 1
            num = ai
        elif sign > 0:
            if ai < num:
                num = ai
                count = 1
                sign = 0
                ans += 1
            else:
                num = ai
        else:
            if ai > num:
                num = ai
                count = 1
                sign = 0
                ans += 1
            else:
                num = ai

if count > 0:
    ans += 1

print(ans)

# Optimized solution
n = int(eval(input()))
a = list(map(int, input().split()))

ans = 1
up = None
for l, r in zip(a, a[1:]):
    if l == r:
        continue
    if l < r:
        if up is None:
            up = True
        elif not up:
            ans += 1
            up = None
    else:
        if up is None:
            up = False
        elif up:
            ans += 1
            up = None

print(ans)
# Original solution
n = int(eval(input()))
aa =list(map(int, input().split()))

list1 =[0] * n
cnt = 0  
for i in range(n-1):
  if aa[i+1] > aa[i]:
    list1[i+1] = 1
  elif aa[i+1] < aa[i]:
    list1[i+1] = -1
  elif aa[i+1] == aa[i]:    
    list1[i+1] = 0

  
while 1 in list1 and -1 in list1:
  if list1[1] == 1:
    for i in range(len(list1)):
      if list1[i] == -1:
        cnt += 1
        list1[i] = 0
        list1 = list1[i:]
        
        break
        
  elif list1[1] == -1:
    for i in range(len(list1)):
      if list1[i] == 1:
        cnt += 1
        list1[i] = 0
        list1 = list1[i:]
        
        break
        
  elif list1[1] == 0:
    for i in range(len(list1)):
      if list1[i] == 1 or list1[i] == -1:
        cnt += 1
        list1[i] = 0
        list1 = list1[i:]
       
        break
  
print((cnt+1))

# Optimized solution
n = int(eval(input()))
aa =list(map(int, input().split()))

list1 =[0] * n
cnt = 1  
for i in range(n-1):
  if aa[i+1] > aa[i]:
    list1[i+1] = 1
  elif aa[i+1] < aa[i]:
    list1[i+1] = -1
  elif aa[i+1] == aa[i]:    
    list1[i+1] = 0

while 1 in list1 and -1 in list1:
  del list1[:max(list1.index(1), list1.index(-1))]
  list1[0] = 0
  cnt += 1
  
print(cnt)
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))
if(N == 1):
    print((1))
    exit(0)
cur = A[0]
# 昇順(1)か降順(0)かのフラグ
ans = 1
flag = -1
for i in range(1, N):
    if(cur == A[i]): continue
    if(flag == -1):
        if(A[i] > cur): flag = 1
        elif(A[i] < cur): flag = 0
        cur = A[i]
        continue
    if(flag == 1 and A[i] < cur):
        cur, flag = A[i], -1
        ans += 1
        continue
    if(flag == 1 and A[i] > cur):
        cur = A[i]
        continue
    if(flag == 0 and A[i] > cur):
        cur, flag = A[i], -1
        ans += 1
        continue
    if(flag == 0 and A[i] < cur):
        cur = A[i]
        continue
print(ans)


# Optimized solution
N = int(eval(input()))
A = list(map(int, input().split()))
if(N == 1):
    print((1))
    exit(0)
cur = A[0]
# 昇順(1)か降順(0)かのフラグ
ans = 1
flag = -1
for i in range(1, N):
    if(cur == A[i]): continue
    if(flag == -1):
        if(A[i] > cur): flag = 1
        elif(A[i] < cur): flag = 0
    elif(flag == 1 and A[i] < cur):
        flag = -1
        ans += 1
    elif(flag == 0 and A[i] > cur):
        flag = -1
        ans += 1
    cur = A[i]
print(ans)
# Original solution
import sys

def solve():
    n = int(input())
    A = [int(i) for i in input().split()]

    flag = 0
    l = 0
    r = 0
    cnt = 0

    while r < n - 1:
        if A[r] == A[r + 1]:
            r += 1
        elif A[r] < A[r + 1]:
            if flag == 2:
                cnt += 1
                flag = 0
                l = r + 1
                r = l
            else:
                flag = 1
                r += 1
        else:
            if flag == 1:
                cnt += 1
                flag = 0
                l = r + 1
                r = l
            else:
                flag = 2
                r += 1

    cnt += 1

    print(cnt)

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

if __name__ == '__main__':
    solve()


# Optimized solution
import sys

def solve():
    n = int(eval(input()))
    a = [int(i) for i in input().split()]

    ans = 0

    mode = 0

    for i in range(1, n):
        if a[i] > a[i - 1]:
            if mode == -1:
                ans += 1
                mode = 0
            else:
                mode = 1
        elif a[i] < a[i - 1]:
            if mode == 1:
                ans += 1
                mode = 0
            else:
                mode = -1
        else:
            pass

    ans += 1

    print(ans)

if __name__ == '__main__':
    solve()
# Original solution
__DEUBG__ = 0

import math
import sys

num = int(eval(input()))
seq = list(map(int, input().split()))

prev = None
tmp = []
increase = None
count = 0

def dump(x):
    from pprint import pprint
    pprint(x)

#breakpoint()

for x in seq:
    if __DEUBG__:
        print(x)
        print(tmp)
    if prev is None:
        tmp = [x]
    elif increase is True:
        if x >= tmp[-1]:
            tmp.append(x)
        else:
            if __DEUBG__:
                dump(tmp)
            tmp = [x]
            increase = None
            count += 1
    elif increase is False:
        if x <= tmp[-1]:
            tmp.append(x)
        else:
            if __DEUBG__:
                dump(tmp)
            tmp = [x]
            increase = None
            count += 1
    elif increase is None:
        if x == tmp[-1]:
            pass
        elif x > tmp[-1]:
            increase = True
        else:
            increase = False
        tmp.append(x)
    prev = x

if __DEUBG__:
    dump(tmp)

count += 1
print(count)


# Optimized solution
num = int(eval(input()))
seq = list(map(int, input().split()))

prev = None
increase = None
count = 0

prev = seq[0]
for x in seq[1:]:
    if increase is True:
        if x >= prev:
            pass
        else:
            increase = None
            count += 1
    elif increase is False:
        if x <= prev:
            pass
        else:
            increase = None
            count += 1
    elif increase is None:
        if x == prev:
            pass
        elif x > prev:
            increase = True
        else:
            increase = False
    prev = x

count += 1
print(count)
# Original solution
N = int(eval(input()))
line = [int(x) for x in input().split(' ')]
count = 1
prev = line[0]
i = 0
while i < len(line):
  if prev == line[i]:
    i += 1
    continue
  elif prev < line[i]:
    for j in range(i,len(line)):
      if line[j] < prev:
        count+=1
        i = j
        break
      prev = line[j]
  elif prev > line[i]:
    for j in range(i,len(line)):
      if line[j] > prev:
        count += 1
        i = j
        break
      prev = line[j]
  prev = line[i]
  i+=1
print(count)


# Optimized solution
N = int(eval(input()))
line = [int(x) for x in input().split(' ')]
count = 1
prev = line[0]
i = 0
while i < len(line):
  if prev == line[i]:
    i += 1
    continue
  elif prev < line[i]:
    for j in range(i,len(line)):
      if line[j] < prev:
        count+=1
        break
      prev = line[j]
    i = j
  elif prev > line[i]:
    for j in range(i,len(line)):
      if line[j] > prev:
        count += 1
        break
      prev = line[j]
    i = j
  prev = line[i]
  i+=1
print(count)
# Original solution
from collections import deque
 
n = int(eval(input()))
a = list(map(int,input().split()))
d = deque(a)
 
tmp = []
cnt = 0
while d:
  v = d.popleft()
  if len(tmp)<=1:
    pass
  else:
    if not (v >= tmp[-1] >= tmp[-2] >= tmp[0] or v <= tmp[-1] <= tmp[-2] <= tmp[0]):
      tmp = []
      cnt += 1
  tmp.append(v)
#  print(d,tmp,cnt)
if tmp:
  cnt+=1
print(cnt)

# Optimized solution
from collections import deque
 
n = int(eval(input()))
a = list(map(int,input().split()))
d = deque(a)
 
tmp = []
cnt = 0
while d:
  v = d.popleft()
  if len(tmp)>=2:
    if not (v >= tmp[-1] >= tmp[0] or v <= tmp[-1] <= tmp[0]):
      tmp = []
      cnt += 1
  tmp.append(v)

print((cnt+1 if tmp else cnt))
# Original solution
def my_sign(n):
    return (n > 0) - (n < 0)
def kugiri(cnt, lst):
    if len(lst) <= 1:
        return cnt
    else:
        pm = lst[0]
        i = 1
        fl = 0
        while i < len(lst):
            if pm == lst[i]:
                i += 1
                continue
            else:
                fl = 1
                break
        if fl == 1:
            new_lst = []
            for j in range(i + 1, len(lst)):
                new_lst.append(lst[j])
            return kugiri(cnt + 1, new_lst)
        else:
            return cnt

N = int(eval(input()))
A_lst = [int(x) for x in input().split()]
cnt = 1
if N == 1:
    pass
else:
    S_lst = []
    for i in range(1, N):
        S_lst.append(my_sign(A_lst[i] - A_lst[i - 1]))
    for i in range(len(S_lst)):
        if i == 0 and S_lst[i] == 0:
            for j in range(len(S_lst)):
                if not S_lst[j] == 0:
                    S_lst[i] = S_lst[j]
        elif S_lst[i] == 0:
            S_lst[i] = S_lst[i - 1]
    cnt = kugiri(cnt, S_lst)
print(cnt)


# Optimized solution
def main():
    N = int(eval(input()))
    lst = [int(_) for _ in input().split()]
    last = lst[0]
    A = [last]
    for i in range(1, N):
        if lst[i] == last: continue
        last = lst[i]
        A.append(lst[i])
    left = right = output = 0
    while left < len(A):
        if left == len(A)-1:
            output += 1
            break
        if A[left+1] - A[left] > 0:
            while right < len(A)-1 and A[right] < A[right+1]:
                right += 1
        elif A[left+1] - A[left] < 0:
            while right < len(A)-1 and A[right] > A[right+1]:
                right += 1
        output += 1
        left = right + 1
        right = left
    print(output)
    return

if __name__ == '__main__':
    main()
# Original solution
from itertools import groupby

N = int(eval(input()))
A = list(map(int, input().split(" ")))

b = [A[i+1]-A[i] for i in range(N-1)]

for i in range(b.count(0)):
    b.remove(0)

b = [0<b_i for b_i in b]

b = [len(list(v)) for k, v in groupby(b)]

# print(b)
if len(b) <= 1:
    print((1))
    exit()

c = 2
can_remove = True
for b_i in b[1:-1]:
    if b_i == 1 and can_remove:
        can_remove = False
    else:
        c += 1
        can_remove = True

print(c)

# Optimized solution
# 傾きの正負の変化を調べるのに、
# AとB(傾き)をかけてその符号を見るという方法があると気づいた
N = int(eval(input()))
A = list(map(int, input().split(" ")))

c = 1
e = 0
for i in range(N-1):
    d = A[i+1]-A[i]
    # print(d, e, e*d < 0)
    # 一方が負の数、もう一方が正の数なら
    if e*d < 0:
        c += 1
        e = 0
    elif d != 0: # この条件忘れた
        e = d

print(c)
# Original solution
n = int(eval(input()))
array = list(map(int, input().split()))
status = 0
past = 0
tail = 0
count = 1
for i in range(1, n):
    past = status
    if(array[i-1] < array[i]):
        if(status == 0):
            past = 1
        status = 1
    elif(array[i-1] > array[i]):
        if (status == 0):
            past = 2
        status = 2

    if(status != past):
        count += 1
        i += 2
        past = 0
        status = 0
        continue




print(count)

# Optimized solution
n = int(eval(input()))
array = list(map(int, input().split()))
status = 0
past = 0
count = 1
for i in range(1, n):
    past = status
    if(array[i-1] < array[i]):
        if(status == 0):
            past = 1
        status = 1
    elif(array[i-1] > array[i]):
        if (status == 0):
            past = 2
        status = 2

    if(status != past):
        count += 1
        i += 2
        past = 0
        status = 0
        continue

print(count)
# Original solution
N = int(eval(input()))
A = list(map(int,input().split()))
ans = 1
t = 0

for k in range(1,N):
    if A[k-1] > A[k]:
        t = -1
        break
    elif A[k-1] < A[k]:
        t = 1
        break
if t==0:
    print((1))
    exit(0)

k = 0
while k < N-1:
    k += 1
    if t == 1:
        if A[k-1] > A[k]:
            ans += 1
            while k+1<N and A[k]==A[k+1]:
                k += 1
            if k == N-1:
                break
            elif A[k] > A[k+1]:
                t = -1
            else:
                t = 1
    else:
        if A[k-1] < A[k]:
            ans += 1
            while k+1<N and A[k]==A[k+1]:
                k += 1
            if k == N-1:
                break
            elif A[k] > A[k+1]:
                t = -1
            else:
                t = 1

print(ans)

# Optimized solution
N = int(eval(input()))
A = list(map(int,input().split()))
A = A
f = 0
ans = 1
for k in range(N-1):
    if f == 0:
        if A[k] > A[k+1]:
            f = -1
        elif A[k] < A[k+1]:
            f = 1
    elif f == 1:
        if A[k] > A[k+1]:
            ans += 1
            f = 0
    else:
        if A[k] < A[k+1]:
            ans += 1
            f = 0
print(ans)
# Original solution
n,*l=list(map(int,open(0).read().split()))
a=b=0
c=0
l+=[0]
while True:
	while l[a]<=l[a+1] and a!=n-1:
		a+=1
	while l[b]>=l[b+1] and b!=n-1:
		b+=1
	a=b=max(a,b)+1
	c+=1
	if a==n-1:
		c+=1
		break
	elif a==n:
		break
print(c)

# Optimized solution
n,*l=list(map(int,open(0).read().split()))
a=b=c=0;f=1;l+=[0,1]
while f:
	while l[a]<=l[a+1]:a+=1
	while l[b]>=l[b+1]:b+=1
	a=b=max(a,b)+1
	c+=1;f=a<n
print(c)
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))
def solve(N,A):
    liss = []
    lis = []
    lis.append(A[0])
    a = A[0]
    for i in range(1,N):
        if len(lis)==1 or prev==0:
            if A[i]>a:
                prev = 1
            elif A[i]<a:
                prev = -1
            else:
                prev = 0
        elif ((A[i]>a)+(A[i]>=a)-1)*prev<0:
            liss.append(lis)
            lis = []
        lis.append(A[i])
        a = A[i]
    liss.append(lis)
    ans = len(liss)
    return ans
print((solve(N,A)))

# Optimized solution
N = int(eval(input()))
A = list(map(int, input().split()))
def solve(N,A):
    liss = []
    lis = []
    lis.append(A[0])
    a = A[0]
    for i in range(1,N):
        if len(lis)==1 or prev==0:
            if A[i]>a:
                prev = 1
            elif A[i]<a:
                prev = -1
            else:
                prev = 0
        elif (A[i]-a)*prev<0:
            liss.append(lis)
            lis = []
        lis.append(A[i])
        a = A[i]
    liss.append(lis)
    ans = len(liss)
    return ans
print((solve(N,A)))
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))
def solve(N,A):
    ans = 1
    lis = [A[0]]
    for i in range(1,N):
        if len(lis)==1 or diff==0:
            diff = A[i]-A[i-1]
        elif (A[i]-A[i-1])*diff<0:
            ans += 1
            lis = []
        lis.append(A[i])
        a = A[i]
    return ans
print((solve(N,A)))

# Optimized solution
N = int(eval(input()))
A = list(map(int, input().split()))
def solve(N,A):
    ans = 1
    lis = [A[0]]
    for i in range(1,N):
        if len(lis)==1 or diff==0:
            diff = A[i]-A[i-1]
        elif (A[i]-A[i-1])*diff<0:
            ans += 1
            lis = []
        lis.append(A[i])
    return ans
print((solve(N,A)))