Harryxun/stf_run huggingface dataset:
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    n = int(input())
    a = [int(x) for x in input().split()]
    b = []
    p = 0
    for e in a:
        if p != e:
            b.append(e)
        p = e

    a = b
    n = len(a)
    p = -1
    ans = 0
    i = 1
    while i < n:
        if a[i-1] > a[i]:
            x = 0
        else:
            x = 1
        if p != x:
            ans += x
        p = x
        i += 1

    print(ans + (not x))

t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""



"""


### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    n = int(input())
    a = [int(x) for x in input().split()]
    b = []
    p = 0
    for e in a:
        if p != e:
            b.append(e)
        p = e
    a = b
    n = len(b)

    ans = 0
    i = 0
    while i < n:
        ans += 1
        if i + 1 == n: break
        else:
            if a[i] < a[i+1]:
                while i + 1 < n and a[i] < a[i+1]:
                    i += 1
                i += 1
            else:
                while i + 1 < n and a[i] > a[i+1]:
                    i += 1
                i += 1
    print(ans)



    

t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""



"""
from math import *

def lcm(x,y):
  return (x*y)//gcd(x,y)

N=int(input())
T=[int(input()) for _ in range(N)]
a=T[0]
for i in range(1,N):
  ans=lcm(a,T[i])
  a=ans
print(ans)


### FIXED CODE ###

from math import gcd

N=int(input())
T=list(int(input()) for _ in range(N))
ans=T[0]
for i in range(1,N):
  ans=ans*T[i]//gcd(ans,T[i])
print(ans)
def p_d():
    N, W = map(int, input().split())
    dp = [[0] * (W + 1) for _ in range(N + 1)]

    for i in range(1, N + 1):
        w, v = map(int, input().split())
        for j in range(1, W + 1):
            if j - w >= 0:
                dp[i][j] = max(v + dp[i - 1][j - w], dp[i - 1][j])
            else:
                dp[i][j] = max(dp[i - 1][j], dp[i][j])

    print(max(dp[N]))


if __name__ == '__main__':
    p_d()


### FIXED CODE ###

def p_e():
    N, W = map(int, input().split())
    max_value = 10 ** 3 * N + 1
    dp = [W + 1] * max_value
    dp[0] = 0
    for _ in range(1, N + 1):
        w, v = map(int, input().split())
        NEXT = [W + 1] * max_value
        NEXT[0] = 0
        for i in range(1, max_value):
            if i - v >= 0:
                NEXT[i] = min(dp[i - v] + w, dp[i])
            else:
                NEXT[i] = dp[i]
        dp = NEXT

    ans = 0
    for i, w in enumerate(dp):
        if w <= W:
            ans = i
    print(ans)


if __name__ == '__main__':
    p_e()
A,B,C=(map(int,input().split())).sort()
print(10*C+B+A)

### FIXED CODE ###

A,B,C=sorted(map(int,input().split()))
print(10*C+A+B)
A=int(input())
B=int(input())
if A<=0 or 10<=A:
    print(-1)
elif B<=0 or 10<=B:
    print(-1)
else:
    print(A*B)


### FIXED CODE ###

x,y = map(int,input().split())
if x<=9 and y<=9:
    print(x*y)
else:
    print(-1)
print("ABC" if int(input()) < 1000 else "ABD")


### FIXED CODE ###

a, b, c = map(int, input().split())
print("YES" if b - a == c - b else "NO")
s = input()
x = ''
for i in range(1, len(s) + 1):
    if i % 2 != 0:
        x = x + s[i]
print(x)

### FIXED CODE ###

s = input()
x = ''
for i in range(0, len(s)):
    if i % 2 == 0:
        x = x + s[i]
print(x)
def main():
    A,B = map(int,input().split())
    import math
    C = math.gcd(A,B)
    cnt = 0
    def make_divisors(n):
        divisors = []
        for i in range(1, int(n**0.5)+1):
            if n % i == 0:
                divisors.append(i)
                if i != n // i:
                    divisors.append(n//i)
        return divisors
    def is_prime(n):
        if n == 1:
            return True
        for i in range(2,int(n**0.5)+1):
            if n % i == 0:
                return False
        return True
    
    C_2 = make_divisors(C)
    
    for i in C_2:
        if is_prime(i):
            cnt += 1
    print(cnt)
    
    


    
if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    A,B = map(int,input().split())
    import fractions
    C = fractions.gcd(A,B)
    cnt = 0
    def make_divisors(n):
        divisors = []
        for i in range(1, int(n**0.5)+1):
            if n % i == 0:
                divisors.append(i)
                if i != n // i:
                    divisors.append(n//i)
        return divisors
    def is_prime(n):
        if n == 1:
            return True
        for i in range(2,int(n**0.5)+1):
            if n % i == 0:
                return False
        return True
    
    C_2 = make_divisors(C)
    
    for i in C_2:
        if is_prime(i):
            cnt += 1
    print(cnt)
    
    


    
if __name__ == '__main__':
    main()
n,m = (int(i) for i in input().split())
x = [int(i) for i in input().split()]

if m == 1:
	print(0)
else:
	sorted_x = sorted(x)

	tupple_diff_x = (sorted_x[i+1] - sorted_x[i] for i in range(m-1))

	list_diff_x = list(tupple_diff_x)

	for i in range(n-1):
		list_diff_x.remove(max(list_diff_x))

	print(sum(list_diff_x))

### FIXED CODE ###

n,m = (int(i) for i in input().split())
x = [int(i) for i in input().split()]

if n >= m:
	print(0)
else:
	sorted_x = sorted(x)
 
	diff_x = []
	diff = 0
	result = 0
 
	for i in range(m-1):
		diff = sorted_x[i+1] - sorted_x[i]
		result += diff
		diff_x.append(diff)

	sorted_diff = sorted(diff_x, reverse=True)[:n-1]
 
	for i in range(n-1):
		result -= sorted_diff[i]
	 
	print(result)
import sys
def get_unique_list(seq):
    seen = []
    return [x for x in seq if x not in seen and not seen.append(x)]

n,m  = map(int,input().split())
l = [list(map(int,input().split())) for _ in range(m)]
d = {}
if m == 0 and n != 0:
    print(10**(n-1))
    sys.exit()
if m = =0 and n == 0:
    print("0")
    
for i in l:
    if i[0] in d and  i[1] !=d[i[0]]:
        d[i[0]] += 1
        print("-1")
        sys.exit()
    else:
        d[i[0]] =i[1]
#ここまでが同一桁に複数の数字が指定されていた時の処理

l = get_unique_list(l) #重複削除
l.sort() #ソート
d = 0
if l[0][1]==0 and l[0][0]==1: #1桁目が0
    if n ==1: #1桁指定の時
        print("0")
        sys.exit()
    else:
        print("-1")
        sys.exit()
        
if l[0][0]!=1: #1桁目に指定がない
    d = 10**(n-1)
    for i in l:
        d += i[1]*10**(n-i[0])
        
else:
    for i in l:
        d += i[1]*10**(n-i[0])    

print(d)

### FIXED CODE ###

import sys
def get_unique_list(seq):
    seen = []
    return [x for x in seq if x not in seen and not seen.append(x)]

n,m  = map(int,input().split())
l = [list(map(int,input().split())) for _ in range(m)]
d = {}
if m == 0 and n != 1:
    print(10**(n-1))
    sys.exit()
if m == 0 and n == 1:
    print("0")
    sys.exit()
    
for i in l:
    if i[0] in d and  i[1] !=d[i[0]]:
        d[i[0]] += 1
        print("-1")
        sys.exit()
    else:
        d[i[0]] =i[1]
#ここまでが同一桁に複数の数字が指定されていた時の処理

l = get_unique_list(l) #重複削除
l.sort() #ソート
d = 0
if l[0][1]==0 and l[0][0]==1: #1桁目が0
    if n ==1: #1桁指定の時
        print("0")
        sys.exit()
    else:
        print("-1")
        sys.exit()
        
if l[0][0]!=1: #1桁目に指定がない
    d = 10**(n-1)
    for i in l:
        d += i[1]*10**(n-i[0])
        
else:
    for i in l:
        d += i[1]*10**(n-i[0])    

print(d)
from math import gcd
import numpy as np
k = int(input())
point = 0
li = [[0 for i in range(k+1)]for j in range(k+1)]
for i in range(1,k+1):
    for j in range(1,k+1):
        li[i][j] = gcd(i,j)
lin = []
for i in li:
    for j in i:
        if j != 0:
            lin.append(j)
for i in lin:
    for j in range(1,k+1):
        point += li[i][j]
print(point)

### FIXED CODE ###

from math import gcd
k = int(input())
point = 0
li = [[0 for i in range(k+1)]for j in range(k+1)]
for i in range(1,k+1):
    for j in range(1,k+1):
        li[i][j] = gcd(i,j)
lin = []
for i in li:
    for j in i:
        if j != 0:
            lin.append(j)
for i in lin:
    for j in range(1,k+1):
        point += li[i][j]
print(point)
import sympy
N = int(input())
print(list(map(sympy.divisor_count,list(range(1,N + 1))[:: 2])).count(8))

### FIXED CODE ###

import math

N = int(input())

def make_prime_list(num):
    if num < 2:
        return []

    prime_list = [i for i in range(num + 1)]
    prime_list[1] = 0 
    num_sqrt = math.sqrt(num)

    for prime in prime_list:
        if prime == 0:
            continue
        if prime > num_sqrt:
            break

        for non_prime in range(2 * prime, num, prime):
            prime_list[non_prime] = 0

    return [prime for prime in prime_list if prime != 0]

def search_divisor_num(num):
    if num < 0:
        return None
    elif num == 1:
        return 1
    else:
        num_sqrt = math.floor(math.sqrt(num))
        prime_list = make_prime_list(num_sqrt)

        divisor_num = 1
        for prime in prime_list:
            count = 1
            while num % prime == 0:
                num //= prime
                count += 1
            divisor_num *= count

        if num != 1:
            divisor_num *= 2

        return divisor_num


print(int(list(map(search_divisor_num,list(range(1,N + 1))[:: 2])).count(8)))
N=int(input())
S=input()
K=int(input())
for i in S:
  if S[K-1]==S[i]:
    S[i]='*'
print(S)

### FIXED CODE ###

input()
S=input()
k=int(input())
for s in S:print(s if s==S[k-1] else "*",end="")
import sys
n = int(input())
h = list(map(int, input().split()))

for i in range(n-1):
    if h[i] > h[i+1] + 1:
        print("No")
        sys.exit()
    
    elif h[i] == h[i+1] + 1 and h[i+1] > h[i+2]:
        print("No")
        sys.exit()

print("Yes")

### FIXED CODE ###

import sys
n = int(input())
h = list(map(int, input().split()))[::-1]

for i in range(1,n):
    if h[i] > h[i-1] + 1:
        print("No")
        sys.exit()
    elif h[i] == h[i-1] + 1:
        h[i] -= 1




print("Yes")
n,m=map(int,input().split())
h=list(map(int,input().split()))
a = [0] * m
b = [0] * m
l=[0]*n
count=0
for i in range(m):
    a[i], b[i]=map(int, input().split())
    l[a-1]=max(l[a-1],h[b-1])
    l[b-1]=max(l[b-1],h[a-1])
for i in range(n):
    if h[i]>l[i]:
        count=count+1
print(count)

### FIXED CODE ###

n, m = map(int, input().split())
h = list(map(int, input().split()))
l = [0]*n
 
for i in range(m):
    a, b = map(int, input().split())
    l[a-1] = max(l[a-1], h[b-1])
    l[b-1] = max(l[b-1], h[a-1])
 
count = 0
for i in range(n):
    if h[i] > l[i]:
        count += 1
 
print(count)
from math import pi

r = int(input())

s = r * r * pi
l = r * 2 * pi

print(s, l)

### FIXED CODE ###

import sys
import math
from decimal import Decimal

r = Decimal(sys.stdin.readline())
area = r ** Decimal(2) * Decimal(math.pi)
circumference = r * Decimal(2) * Decimal(math.pi)

print(round(area, 5), round(circumference, 5))
n = int(input())
a = list(map(int, input().split()))
q = int(input())

s = sum(a)

num = [0]*10**5

for i in range(10**5):
    num[i] = a.count(i)

for i in range(q):
    b, c = map(int, input().split())
    d = (c-b) * num[b]
    num[c] += num[b]
    num[b] = 0
    s += d
    print(s)


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
q = int(input())
bc = list(map(int, input().split()) for _ in range(q))

s = sum(a)

num = [0]*(10**5 + 1)
for x in a:
    num[x] += 1

for b, c in bc:
    s += (c - b)*num[b]
    num[c] += num[b]
    num[b] = 0

    print(s)
N,M = map(int,input().split())

E_list = [[]for i in range(N)]

marks = [False for i in range(N)]

def dfs(n):
    global E_list
    global marks
    global N,M

    marks[n] = True

    steps = 1

    for nx in E_list[n]:
        if not marks[nx]:
            marks[nx] = True
            steps += dfs(nx)
    
    return steps



for i in range(M):
    e1,e2 = map(int,input().split())
   
    E_list[e1-1].append(e2-1)
    E_list[e2-1].append(e1-1)

m = 1


for i in range(N):
    E_list[i] = list(set(E_list[i]))
for i in range(N):
    if not marks[i]:
        st = dfs(i)

    m = max(m,st)


print(m)

### FIXED CODE ###

import sys

sys.setrecursionlimit(10**6)

N,M = map(int,input().split())

E_list = [[]for i in range(N)]

marks = [False for i in range(N)]
m = 1
def dfs(n):
    global E_list
    global marks
    global N,M

    marks[n] = True

    steps = 1

    for nx in E_list[n]:
        if not marks[nx]:
            marks[nx] = True
            steps += dfs(nx)
    
    return steps



for i in range(M):
    e1,e2 = map(int, input().split())
   
    E_list[e1-1].append(e2-1)
    E_list[e2-1].append(e1-1)


for i in range(N):
    E_list[i] = list(set(E_list[i]))

for i in range(N):
    if not marks[i]:
        st = dfs(i)

    m = max(m,st)

print(m)
n,q=map(int,input().split())

l=[list() for i in range(n)]
c=[0]*n

def ladd(p,q):
  c[p]+=q
  for i in l[p]:
    ladd(i,q)

for i in range(n-1):
  a,b=map(int,input().split())
  l[a-1].append(b-1)

for i in range(q):
  p,q=map(int,input().split())
  ladd(p-1,q)

print(c)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)
input=sys.stdin.readline

n,q=map(int,input().split())
t=[[] for _ in range(n)]
c=[0 for _ in range(n)]

for i in range(n-1):
  a,b=map(int,input().split())
  t[a-1].append(b-1)
  t[b-1].append(a-1)

for i in range(q):
  p,x=map(int,input().split())
  c[p-1]+=x

def dsf(ci,pi):
  for i in t[ci]:
    if i != pi:
      c[i] += c[ci]
      dsf(i, ci)

dsf(0,-1)

print(*c)
n=int(input())

result=0
for item in range(n):
  a,b=map(str,input().split())
  if b=="JPY":
    result+=int(a)
  else:
    result+=int(a)*380000.0
print(result)

### FIXED CODE ###

n=int(input())

result=0
for item in range(n):
  a,b=map(str,input().split())
  if b=="JPY":
    result+=float(a)
  else:
    result+=float(a)*380000.0
print(result)
print(input().count("+")-input().count("-"))

### FIXED CODE ###

a=input()
print(a.count("+")-a.count("-"))
x = int(input())
a = set()

for i in range(2,32):
    for j in range(10):
        if i ** j >= x:
            break
        a.add(i ** j)
print(max(a))

### FIXED CODE ###

x = int(input())
a = [1]

for i in range(2,32):
    for j in range(2,11):
        if i ** j > x:
            break
        a.append(i ** j)
print(max(a))
a = list(map(int,input().split()))
   print(max((a[2]-(a[0]-a[1])),0))



### FIXED CODE ###

a = list(map(int,input().split()))
if a[2]>(a[0]-a[1]):
    print(a[2]-(a[0]-a[1]))
else:print(0)
import math

s=list(input().split('T'))
sn=[]

for i in range(len(s)):
    sn.append(len(s[i]))

x, y = map(int,input().split(' '))
x = x-sn[0]

snx=[]
sny=[]

for i in range(2,len(sn),2):
    snx.append(sn[i])

for i in range(1,len(sn),2):
    sny.append(sn[i])

#X軸判定
xflg = 0
ansx=[]
prex=[0]
for i in range(len(snx)):
    tmpx=set()
    for j in prex:
        tmpx.add(j+snx[i])
        tmpx.add(j-snx[i])
    prex=tmpx

if x in tmpx:
    xflg = 1

#y軸判定
yflg = 0
prey=[0]
for i in range(len(sny)):
    tmpy=set()
    for j in prey:
        tmpy.add(j+sny[i])
        tmpy.add(j-sny[i])
    prey=tmpy

if y in tmpy:
    yflg = 1

if xflg == 1 and yflg == 1:
    print("Yes")
else:
    print("No")



### FIXED CODE ###

import math

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

a = A1[0]*1.0
b = A1[1]*1.0

print(math.ceil( ( a + b ) / 2 ))
S=input()

if S = "ABC":
  print("ARC")
else:
  print("ABC")
  


### FIXED CODE ###

S=input()

if S == "ABC":
  print("ARC")
else:
  print("ABC")
A, B, C, K = list(map(int,input().split()))
count = 0
s = 0
while K > 0:
	if count < A:
		s += 1
	elif count >= A+B:
		s -= 1
	K -= 1
	count += 1
print(s)


### FIXED CODE ###

S = input()
T = input()
N = len(T)
T2 = T[0:N-1]
if S == T2:
	print('Yes')
else:
	print('No')
n = int(input())
h = list(map(int, input().split()))
# dp = [[None] * 10**6 for _ in range(n)]
dp = [None] * (n+1)

# Return the smallest cost to reach the idx
def solve(idx):
    if dp[idx] is not None:
        return dp[idx]

    if idx == 1:
        dp[idx] = abs(h[idx] - h[idx - 1])
    elif idx == 0:
        dp[idx] = 0
    else:
        # jump from idx - 1
        c1 = solve(idx - 1) + abs(h[idx] - h[idx - 1])

        # jump from idx - 2
        c2 = solve(idx - 2) + abs(h[idx] - h[idx - 2])

        dp[idx] = min(c1, c2)

    return dp[idx]

ans = solve(n-1)

print(ans)

### FIXED CODE ###

n = int(input())
hs = list(map(int, input().split()))
dp = [0]*n

# cost1 = dp[i-1] + abs(dp[i-1]-dp[i])
# cost2 = dp[i-2] + abs(dp[i-2]-dp[i])
# dp[i] = min(cost1, cost2)

#for i in reversed(range(n)):
for i in range(n):
    if i == 0:
        dp[0] = 0
    elif i == 1:
        dp[1] = abs(hs[0]-hs[1])
    else:
        cost1 = dp[i-1] + abs(hs[i-1]-hs[i])
        cost2 = dp[i-2] + abs(hs[i-2]-hs[i])
        dp[i] = min(cost1, cost2)

print(dp[n-1])
s = input()

wa = False

if s[0] != 'A':
  wa = True

if s[2:-1].count('C') != 1:
  wa = True

l_s = list(s)
  
del l_s[l_s.index('A')]
del l_s[l_s.index('C')]

for c in l_s:
  if c != c.lower():
    wa = True
    
if wa == True:
  print('WA')
else:
  print('AC')

### FIXED CODE ###

s = input()

wa = False

if s[0] != 'A':
  wa = True
if s[2:-1].count('C') != 1:
  wa = True

l_s = list(s)
  
if 'A' in l_s:
	del l_s[l_s.index('A')]

if 'C' in l_s:
	del l_s[l_s.index('C')]

for c in l_s:
  if c != c.lower():
    wa = True
    
if wa == True:
  print('WA')
else:
  print('AC')
a,b = map(int(input().split())
print(a*b)

### FIXED CODE ###


a,b = map(int,input().split())
print(a*b)
A = int(input())
B = int(input())
 
if A <= 8:
    if B <= 8:
        print('Yay!')
    else:
        print( ':(') 
else:
    print( ':(')

### FIXED CODE ###

A,B = map(int,input().split())
 
if A <= 8:
    if B <= 8:
        print('Yay!')
    else:
        print( ':(') 
else:
    print( ':(')
n=int(input())
s=[]
for i in range(n):
    i=input()
    s.append(i[0])

import collections
c = collections.Counter(s)
d=['M','A','R','C','H']
ans=0
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            ans+=c[d[i]]*c[d[j]]*c[d[k]]
print(ans)
            


### FIXED CODE ###

n=int(input())
s=['M','A','R','C','H']
for i in range(n):
    i=input()
    s.append(i[0])

import collections
c = collections.Counter(s)
d=['M','A','R','C','H']
ans=0
for i in range(3):
    for j in range(i+1,4):
        for k in range(j+1,5):
            ans+=(c[d[i]]-1)*(c[d[j]]-1)*(c[d[k]]-1)
print(ans)
n,d = map(int, input().split())
print(n // (2d + 1) + 1)

### FIXED CODE ###

import math

n,d = map(int, input().split())
print(math.ceil(n / (2*d + 1)))
import sys
sys.setrecursionlimit(10**8)

K = int(input())

for i in [2,5]:
    if K%i==0:
        print(-1)
        exit()

def f(i,t,K):
    t2 = (t*10+7)%K
    if t2==0:
        print(i)
        exit()
    else:f(i+1,t2,K)
f(1,0,K)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**8)

K = int(input())

for i in [2,5]:
    if K%i==0:
        print(-1)
        exit()
t = 0
for i in range(K):
    t = (t*10+7)%K
    if t == 0:
        print(i+1)
        exit()
print(-1)
from collections import Counter
S=input()
T=input()
s=list(S)
t=list(T)
a=Counter(s)
b=Counter(t)
c=a.most_common()
d=b.most_common()
flag=True
for i in range(len(s)):
    if d[i][1]==1 and c[i][1]==1:
        break
    if d[i][1]>=2 and flag:
        e=[]
        for j in range(len(s)):
            if t[j]==d[i][0]:
                e.append(s[j])
        for j in range(len(e)-1):
            if e[j]!=e[j+1]:
                flag=False
                break
    if c[i][1]>=2 and flag:
        f=[]
        for j in range(len(s)):
            if s[j]==c[i][0]:
                f.append(t[j])
        for j in range(len(f)-1):
            if f[j]!=f[j+1]:
                flag=False
                break
if flag:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

from collections import Counter
S=input()
T=input()
s=list(S)
t=list(T)
a=Counter(s)
b=Counter(t)
c=a.most_common()
d=b.most_common()
flag=True
for i in range(min(len(d),len(c))):
    if d[i][1]==1 and c[i][1]==1:
        break
    if d[i][1]>=2 and flag:
        e=[]
        for j in range(len(s)):
            if t[j]==d[i][0]:
                e.append(s[j])
        for j in range(len(e)-1):
            if e[j]!=e[j+1]:
                flag=False
                break
    if c[i][1]>=2 and flag:
        f=[]
        for j in range(len(s)):
            if s[j]==c[i][0]:
                f.append(t[j])
        for j in range(len(f)-1):
            if f[j]!=f[j+1]:
                flag=False
                break
if flag:
    print('Yes')
else:
    print('No')
import sys
lines = sys.stdin.readlines()
 
N, X = lines.strip("\n")
X = map(int, X.strip(" "))
 
res = float('inf')
for i in Range(1, 101):
  cur_res = 0
  for j in X:
    cur_res = cur_res + (j-i)^2
  if cur_res < res:
    res = cur_res
 
print(cur_res)

### FIXED CODE ###

N=int(input())
Xs = list(map(int, input().split()))

res=0
for i in Xs:
    res = res + (i-round(sum(Xs)/N))**2

print(res)
import math

def main():
  t1, t2 = map(int, input().split())
  a1, a2 = map(int, input().split())
  b1, b2 = map(int, input().split())

  sumA = t1 * a1 + t2 * a2
  sumB = t1 * b1 + t2 * b2

  if sumA == sumB:
    return 'infinity'
  if sumA < sumB:
    sumA, sumB = sumB, sumA
    a1, b1 = b1, a1
    a2, b2 = b2, a2
  # A の方が sum が大きいとする

  halfA = t1 * a1
  halfB = t1 * b1
  if halfA > halfB:
    return 0
  div, mod = divmod(halfB - halfA, sumA - sumB)
  if mod == 0
    return div * 2
  return div * 2 + 1

print(main())

### FIXED CODE ###

import math

def main():
  t1, t2 = map(int, input().split())
  a1, a2 = map(int, input().split())
  b1, b2 = map(int, input().split())

  sumA = t1 * a1 + t2 * a2
  sumB = t1 * b1 + t2 * b2

  if sumA == sumB:
    return 'infinity'
  if sumA < sumB:
    sumA, sumB = sumB, sumA
    a1, b1 = b1, a1
    a2, b2 = b2, a2
  # A の方が sum が大きいとする

  halfA = t1 * a1
  halfB = t1 * b1
  if halfA > halfB:
    return 0
  div, mod = divmod(halfB - halfA, sumA - sumB)
  if mod == 0:
    return div * 2
  return div * 2 + 1

print(main())
(h, w) = map(int, input().split(" "))

ans=[]
### case1  000
ans.append(0 if h%3==0 else w)
###case 2 tate 000
ans.append(0 if w%3==0 else h)

def getmin(h, w):
    area=9999999999999
    for i in range(h):
        for j in range(w):
            areas=[ i * w, j * (h-i), (w-j)*(h-i)]
            area = min(areas) if area > min(areas)
    return area

ans.append(getmin(h, w))
ans.append(getmin(w, h))

print(min(ans))


### FIXED CODE ###

(h, w) = map(int, input().split(" "))

ans=[]
### case1  000
ans.append(0 if h%3==0 else w)
###case 2 tate 000
ans.append(0 if w%3==0 else h)

def getmin(h, w):
    area=9999999999999
    for i in range(h//3-3, h//3+2):
        for j in range(w//2 -3, w//2 +3):
            areas=[ i * w, j * (h-i), (w-j)*(h-i)]
            area = max(areas)-min(areas) if area > max(areas)-min(areas) else area
    return area

ans.append(getmin(h, w))
ans.append(getmin(w, h))

print(min(ans))
N = int(input())
a = list(map(int, input().split()))

count = 0

for i in range(int(N/2)+1):
  cd = 2 * i
  jd = a[cd]
  if jd % 2 == 1:
    count += 1

print(count)

### FIXED CODE ###

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

count = 0

for i in range(0,N,2):
  jd = a[i]
  if jd % 2 == 1:
    count += 1

print(count)
n = int(input())
list = list(map(int,input().split(' ')))

def getTargetIndex():
    diffList = []
    for i in range(0,n-1):
        left = 0
        right = 0
        left = list[:i+1]
        right = list[i+1:]
        diffList.append(abs(sum(left)- sum(right)))  
    return list.index(min(diffList))

div = getTargetIndex()
left = list[:div]
right = list[div:]
print(abs(sum(left) -sum(right)) )

### FIXED CODE ###

n = input().split(' ')
third = 100000
second = 200000
first = 300000
sum = 0
for i in n:
    if int(i) == 3:
        sum = sum + third
    elif  int(i) == 2:
        sum = sum + second
    elif  int(i) == 1:
        sum = sum + first

if int(n[0]) == 1 and int(n[1]) == 1:
    sum = sum + 400000

print(sum)