n = int(eval(input()))

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

cnt = 1

fl = 0

for i in range(1,n):

    if fl==1 and a[i]<a[i-1]:

        cnt+=1

        fl=0

    elif fl==-1 and a[i]>a[i-1]:

        cnt+=1

        fl=0

    elif fl==0 and a[i]<a[i-1]:

        fl = -1

    elif fl==0 and a[i]>a[i-1]:

        fl = 1

print(cnt)
def solve():

    n = int(eval(input()))

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

    direction = 0 # 0なら未定　－１なら減少，１なら増加

    cnt = 1

    for i in range(1,n):

        if (a[i]-a[i-1])*direction<0:

            cnt+=1

            direction = 0

        else:

            if direction==0:

                direction = a[i]-a[i-1]

    print(cnt)

if __name__ == "__main__":

    solve()
n = int(eval(input()))
a = list(map(int, input().split()))
cnt = 1
fl = 0
for i in range(1, n):
    if fl == 1 and a[i] < a[i - 1]:
        cnt += 1
        fl = 0
    elif fl == -1 and a[i] > a[i - 1]:
        cnt += 1
        fl = 0
    elif fl == 0 and a[i] < a[i - 1]:
        fl = -1
    elif fl == 0 and a[i] > a[i - 1]:
        fl = 1
print(cnt)

def solve():
    n = int(eval(input()))
    a = list(map(int, input().split()))
    direction = 0  # 0なら未定　－１なら減少，１なら増加
    cnt = 1
    for i in range(1, n):
        if (a[i] - a[i - 1]) * direction < 0:
            cnt += 1
            direction = 0
        else:
            if direction == 0:
                direction = a[i] - a[i - 1]
    print(cnt)


if __name__ == "__main__":
    solve()

-n = int(eval(input())) -a = list(map(int, input().split())) -cnt = 1 -fl = 0 -for i in range(1, n): -    if fl == 1 and a[i] < a[i - 1]: -        cnt += 1 -        fl = 0 -    elif fl == -1 and a[i] > a[i - 1]: -        cnt += 1 -        fl = 0 -    elif fl == 0 and a[i] < a[i - 1]: -        fl = -1 -    elif fl == 0 and a[i] > a[i - 1]: -        fl = 1 -print(cnt) +def solve(): +    n = int(eval(input())) +    a = list(map(int, input().split())) +    direction = 0  # 0なら未定　－１なら減少，１なら増加 +    cnt = 1 +    for i in range(1, n): +        if (a[i] - a[i - 1]) * direction < 0: +            cnt += 1 +            direction = 0 +        else: +            if direction == 0: +                direction = a[i] - a[i - 1] +    print(cnt) + + +if __name__ == "__main__": +    solve()