Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

from collections import deque

h, w = map(int, input().split())
Ch, Cw = map(int, input().split())
Dh, Dw = map(int, input().split())
Ch -= 1
Cw -= 1
Dh -= 1
Dw -= 1
t = [[i for i in range(w)] for j in range(h)]
ans = 0
for i in range(h):
  temp = input()
  for j in range(w):
    t[i][j] = temp[j]

d = deque()
d1 = deque()
d.append((Ch, Cw))
ans = 0
s = set() # いったところ
a = [(1,0),(-1,0),(0,1),(0,-1)]
b = [-2,-1,0,1,2]
while True:
  # 行けるところすべて追加
  targets = set()
  while len(d) > 0:
    temps = set(d)
    targets |= temps
    d = deque()
    for Th, Tw in temps:
      for i,j in a:
        _h = Th + i
        _w = Tw + j
        _p = (_h, _w)
        if (not (_p) in s) and _h >= 0 and _h < h and _w >= 0 and _w < w and t[_h][_w] == '.':
          d.append(_p)
          s.add((Th,Tw))
  # クリアしてるか確認
  if (Dh,Dw) in targets:
    print(ans)
    exit()
  else:
    s |= targets
    d = deque()
    for Th,Tw in targets:
      for i in b:
        for j in b:
          _h = Th + i
          _w = Tw + j
          _p = (_h, _w)
          if (not (_p) in s) and (not (_p) in d) and _h >= 0 and _h < h and _w >= 0 and _w < w and t[_h][_w] == '.':
            d.append(_p)
    if len(d) == 0:
      print('-1')
      exit()
    ans += 1


### FIXED CODE ###

from collections import deque

h, w = map(int, input().split())
Ch, Cw = map(int, input().split())
Dh, Dw = map(int, input().split())
Ch -= 1
Cw -= 1
Dh -= 1
Dw -= 1
t = [[i for i in range(w)] for j in range(h)]
visited = [[0 for i in range(w)] for j in range(h)] # いったところ
ans = 0
for i in range(h):
  temp = input()
  for j in range(w):
    t[i][j] = temp[j]

d = deque([(Ch, Cw)])
ans = 0
a = [(1,0),(-1,0),(0,1),(0,-1)]

while True:
  # 移動A
  stemp = set()
  while len(d) != 0:
    Th, Tw = d.popleft()
    # s.add((Th, Tw))
    visited[Th][Tw] = 1
    stemp.add((Th, Tw))
    if (Th,Tw) == (Dh, Dw):
      print(ans)
      exit()
    for i, j in a:
      _h,_w = Th + i, Tw + j
      _p = (_h, _w)
      if 0 <= _h < h and 0 <= _w < w and t[_h][_w] == '.' and visited[_h][_w] == 0:
        d.append(_p)
        visited[_h][_w] = 1
  # 移動B
  ans += 1
  for Th,Tw in stemp:
    for i in range(-2, 3) :
      for j in range(-2, 3) :
        _h,_w = Th + i, Tw + j
        _p = (_h, _w)
        if 0 <= _h < h and 0 <=  _w < w and t[_h][_w] == '.' and visited[_h][_w] == 0:
          d.append(_p)
  if len(d) == 0:
    print('-1')
    exit()
### BUGGY CODE ###

def ABC_102_A():
    N = int(input())

    for i in range(1000000000):
         if 2*i%N == 0 and i>0:
             print(2*i)
             break
         else:
             continue
         break
 


if __name__ == '__main__':

    ABC_102_A()

### FIXED CODE ###

def ABC_102_A():
    N = int(input())

    if N%2 == 0:
        print(N)
    else:
        print(2*N)

if __name__ == '__main__':

    ABC_102_A()
### BUGGY CODE ###

def f_small_products(N, K, MOD=10**9 + 7):
    # 参考: https://atcoder.jp/contests/abc132/submissions/6187073
    sqrt_n = int(N**0.5)

    # num: 0 <= i <= Nについて、N // i の値で同一視できるものの個数が前から格納される
    num = [0 for i in range(2 * sqrt_n + 1)]
    # 1から√N までは、同一視できるものの個数は1つ
    for i in range(1, sqrt_n + 1):
        num[i] = 1
    # √NからN までは、複数の整数が同一視されることがある
    for i in range(1, sqrt_n + 1):
        lo = max(sqrt_n + 1, (N + i + 1) // (i + 1))
        hi = N // i
        num[2 * sqrt_n + 1 - i] = hi - lo + 1

    # dp[n][m]: 最後の整数が m であるような n 個の整数を
    # 並べて条件を満たすようにする場合の数
    dp = [[0 for j in range(2 * sqrt_n + 2)] for i in range(K + 1)]
    dp[0][1] = 1  # 数列の先頭のさらに1個前に1があるとみなす(置き方1通り)
    for i in range(K):
        # 累積和を用いたdpテーブルの更新(imos法)
        for j in range(1, 2 * sqrt_n + 1):
            ways = (dp[i][j] * num[j]) % MOD
            dp[i + 1][1] += ways
            dp[i + 1][2 * sqrt_n + 2 - j] -= ways
        for j in range(1, 2 * sqrt_n + 1):
            dp[i + 1][j] += dp[i + 1][j - 1]

    return sum(a * b for a, b in zip(dp[K], num)) % MOD

N, K = [int(i) for i in input().split()]
print(f_small_products(N, K))

### FIXED CODE ###

def f_small_products(N, K, MOD=10**9 + 7):
    # 参考: https://atcoder.jp/contests/abc132/submissions/6187073
    sqrt_n = int(N**0.5)

    # num: 0 <= i <= Nについて、N // i の値で同一視できるものの個数が前から格納される
    num = [0 for i in range(2 * sqrt_n + 1)]
    # 1から√N までは、同一視できるものの個数は1つ
    for i in range(1, sqrt_n + 1):
        num[i] = 1
    # √NからN までは、複数の整数が同一視されることがある
    for i in range(1, sqrt_n + 1):
        lo = max(sqrt_n + 1, (N + i + 1) // (i + 1))
        hi = N // i
        num[2 * sqrt_n + 1 - i] = hi - lo + 1

    # dp[n][m]: 最後の整数が m であるような n 個の整数を
    # 並べて条件を満たすようにする場合の数
    dp = [[0 for j in range(2 * sqrt_n + 2)] for i in range(K + 1)]
    dp[0][1] = 1  # 数列の先頭のさらに1個前に1があるとみなす(置き方1通り)
    for i in range(K):
        # 累積和を用いたdpテーブルの更新(imos法)
        for j in range(1, 2 * sqrt_n + 1):
            ways = (dp[i][j] * num[j]) % MOD
            dp[i + 1][1] += ways
            dp[i + 1][2 * sqrt_n + 2 - j] -= ways
        for j in range(1, 2 * sqrt_n + 1):
            dp[i + 1][j] += dp[i + 1][j - 1]

    return sum(a * b for a, b in zip(dp[K], num)) % MOD

N, K = [int(i) for i in input().split()]
print(f_small_products(N, K))
### BUGGY CODE ###

#! /usr/bin/env python3
# -*- coding: utf-8 -*-
import collections
N,M = [int(x) for x in input().split()]
ans =[0]*N
for i in range (M):
    L,R = [int(x) for x in input().split()]
    ans[L-1:R] = map(lambda x: x+1, ans[L-1:R] )



       

print(ans.count(M))







### FIXED CODE ###

#! /usr/bin/env python3
# -*- coding: utf-8 -*-
N,M = [int(x) for x in input().split()]
Llist =[]
Rlist =[]
for i in range (M):
    L,R = [int(x) for x in input().split()]
    Llist.append(L)
    Rlist.append(R)
 
lmax = max(Llist)
Rmax = min(Rlist)

if lmax > Rmax:
    print(0)
else:
    print(Rmax-lmax+1)
### BUGGY CODE ###

import math

n = int(raw_input())
a = raw_input().split()

cnt = 0
for i in a:
    a[cnt] = int(i)
    cnt += 1

chk = {}
def make_divisors(k):
    divisors = []
    for i in range(1, int(k**0.5)+1):
        if k % i == 0:
            #divisors.append(i)
            if i in chk:
                chk[i] += 1
            else:
                chk[i] = 1
            if i != k // i:
                #divisors.append(n//i)
                key = int(k//i)
                if key in chk:
                    chk[key] += 1
                else:
                    chk[key] = 1

    # divisors.sort()
    return divisors

if n == 2:
    print max(a[0],a[1])
else:
    for i in range(2):
        make_divisors(a[i])
    cnt = 1
    for i in reversed(range(2,len(a))):
        k = a[i]
        del_list = []
        for j in chk:
            if k % j == 0:
                chk[j] += 1
            if chk[j] < cnt+1:
                del_list.append(j)
        for j in del_list:
            del chk[j]
        cnt += 1

    answer = 0
    for i in chk:
        if int(chk[i]) >= n - 1 and i > answer:
            answer = i
    print answer

### FIXED CODE ###

n = int(raw_input())
a = raw_input().split()

cnt = 0
for i in a:
    a[cnt] = int(i)
    cnt += 1

chk = {}
chk2 = {}
def make_divisors(k):
    divisors = []
    for i in range(1, int(k**0.5)+1):
        if k % i == 0:
            if i in chk:
                chk[i] += 1
            else:
                chk[i] = 1
            if i != k // i:
                key = int(k//i)
                if key in chk:
                    chk[key] += 1
                else:
                    chk[key] = 1
    return divisors

for i in range(2):
    make_divisors(a[i])
cnt = 1
for i in range(2,len(a)):
    k = a[i]
    if k not in chk2:
        chk2[k] = 1
    else:
        if chk2[k] == 1:
            chk2[k] += 1
        elif chk2[k] > 1:
            continue
    del_list = []
    for j in chk:
        if k % j == 0:
            chk[j] += 1
        if chk[j] < cnt+1:
            del_list.append(j)
    for j in del_list:
        del chk[j]
    cnt += 1

answer = 0
for i in chk:
    if int(chk[i]) >= chk[1] - 1 and i > answer:
        answer = i
print answer
### BUGGY CODE ###

import math
N = int(input())
ans=0
for i in range(1,N+1):
  for j in range(1, N+1):
    for k in range(1, N+1):
        t=math.gcd(i,j)
        t=math.gcd(t,k)
        ans+=t

print(ans)


### FIXED CODE ###

def main():
  import math
  N = int(input())
  gcd={}
  ans=0
  for i in range(1,N+1):
    for j in range(1, N+1):
      key=i*N+j
      gcd[key]=math.gcd(i,j)
  
  for k, i in gcd.items():
    for j in range(1, N+1):
      key=j*N+i
      ans+=gcd[key]
        
  print(ans)
 
if __name__=='__main__':
  main()
### BUGGY CODE ###

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

l, r = map(int, input().split())
ans = set(range(l, r+1))
for i in range(m-1):
    l, r = map(int, input().split())
    ans = ans & set(range(l, r + 1))
print(len(ans))


### FIXED CODE ###

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

l, r = 0, 10 ** 6
for i in range(m):
    tl, tr = map(int, input().split())
    l = max(tl, l)
    r = min(tr, r)
print(len(range(l, r+1)))
### BUGGY CODE ###

from queue import Queue
import sys
input = sys.stdin.readline


def main():
    H, W = map(int, input().split())

    l = 0
    q = Queue()
    checked = []
    for h in range(H):
        S = input()
        L = []
        for w in range(W):
            if S[w] == '#':
                l += 1
                L.append(True)
                q.put((h, w))
            else:
                L.append(False)
        checked.append(L)

    Next = [[[] for _ in range(W)] for _ in range(H)]
    for h in range(H):
        for w in range(W):
            if h != 0:
                Next[h][w].append((h-1, w))
            if h != H-1:
                Next[h][w].append((h+1, w))
            if w != 0:
                Next[h][w].append((h, w-1))
            if w != W-1:
                Next[h][w].append((h, w+1))

    c = -1
    while True:
        nl = 0
        if q.empty():
            break
        for _ in range(l):
            (h, w) = q.get()
            for nh, nw in Next[h][w]:
                if not checked[nh][nw]:
                    q.put((nh, nw))
                    checked[nh][nw] = True
                    nl += 1
        l = nl
        c += 1
    print(c)


if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys
input = sys.stdin.readline

B = int(1E8)

def main():

    H, W = map(int, input().split())
    
    l = 0
    q = []
    checked = []
    for h in range(H):
        S = input()
        L = []
        for w in range(W):
            if S[w] == '#':
                l += 1
                L.append(True)
                q.append(B*h+w)
            else:
                L.append(False)
        checked.append(L)

    Next = [[[] for _ in range(W)] for _ in range(H)]
    for h in range(H):
        for w in range(W):
            if h != 0:
                Next[h][w].append(B*(h-1) + w)
            if h != H-1:
                Next[h][w].append(B*(h+1) + w)
            if w != 0:
                Next[h][w].append(B*h + w-1)
            if w != W-1:
                Next[h][w].append(B*h + w+1)

    c = -1
    for _ in range(H+W+2):
        qq = []
        if len(q) == 0:
            break
        for hw in q:
            h, w = hw//B, hw%B
            for nhw in Next[h][w]:
                nh, nw = nhw//B, nhw%B
                if not checked[nh][nw]:
                    qq.append(B*nh + nw)
                    checked[nh][nw] = True
        q = qq
        c += 1

    print(c)


if __name__ == "__main__":
    main()
### BUGGY CODE ###

def permutations(iterable, permutation=[]):
    if not iterable: 
        yield permutation
        pass
    for i in [iterable.index(i) for i in set(iterable)]:
        yield from permutations(iterable[:i] + iterable[i+1:], permutation + [iterable[i]])


K,S=map(int,input().split())
ans=0

l=[]
for i in range(K+1):
  for j in range(i,K+1):
    for k in range(j,K+1):
      if i+j+k==S:
        l.append([i,j,k])

for item in l:
  for v in permutations(item):
    ans+=1
print(ans)

### FIXED CODE ###

import itertools

K,S=map(int,input().split())

ans=0
for i in range(K+1):
  for j in range(K+1):
    if 0<=S-(i+j)<=K:
      ans+=1
print(ans)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
"""
Created on Tue Jan 21 18:19:39 2020

@author: matsui
"""


N,W=map(int,input().split())
vi,wi=[],[]
for i in range(N):
    w,v=map(int,input().split())
    wi.append(w)
    vi.append(v)

M=int(sum(vi))
dp1=[sum(wi)+1]*(M+1)
dp2=[sum(wi)+1]*(M+1)
dp1[0]=0
   
#L = sorted([list(map(int,input().split())) for i in range(N)])
s=0

for w, v in zip(wi,vi):
    for j in range(M+1):
        if j >= v: 
            if dp2[j] > dp1[j-v]+w: dp2[j]=dp1[j-v]+w
        if dp2[j] > dp1[j]: dp2[j]=dp1[j]
    #print(dp1)
    #print(dp2)
    dp1=[dp2[i] for i in range(M+1)]    
    
#print(max(dp))
m=0
for i in range(M+1):
    if dp2[i]<=W:
        m=i
print(m)
    


### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Tue Jan 21 18:19:39 2020

@author: matsui
"""


N,W=map(int,input().split())
vi,wi=[],[]
for i in range(N):
    w,v=map(int,input().split())
    wi.append(w)
    vi.append(v)
    

#L = sorted([list(map(int,input().split())) for i in range(N)])

M=int(sum(vi))
dp=[W+1]*(M+1)
dp[0]=0
   
#L = sorted([list(map(int,input().split())) for i in range(N)])
s=0

for w, v in zip(wi,vi):
    s+=v
    for j in range(min(s,M),v-1,-1):
        if dp[j] > dp[j-v]+w: dp[j]=dp[j-v]+w
    #print(dp)

m=0
for i in range(M+1):
    if dp[i]<=W:
        m=i
print(m)
### BUGGY CODE ###

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

count = 0

for i in range(N - K + 1):
  kake_A = 1
  for j in range(K):
    kake_A = kake_A * A[j + i]
  count = count + 1
  if count == 1:
    kake_B = kake_A
    continue
  else:
    if kake_A > kake_B:
      print('Yes')
    else:
      print('No')
    kake_B = kake_A

### FIXED CODE ###

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

count = 0

for i in range(N - K):
  kake_A = A[i]
  kake_B = A[i + K]
  if kake_A >= kake_B:
    print('No')
  else:
    print('Yes')
### BUGGY CODE ###

# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_10_C

????????±?????¨??????
"""
import sys
from sys import stdin
input = stdin.readline



def calc_lcs4(X, Y):
    X = ' ' + X
    Y = ' ' + Y
    m = len(X)
    n = len(Y)

    C = [[0]*(n+1) for _ in range(m+1)] #  ???????????§??¨???

    max_lcs = 0

    pre_row = C[0]
    for i in range(1, m):
        row = C[i]
        XX = X[i]
        for j, YY in enumerate(Y):
            if XX == YY:
                pr_j1 = pre_row[j - 1]
                row[j] = pr_j1 + 1
                if pr_j1+1 > max_lcs:
                   max_lcs = pr_j1 + 1
            else:
                pr_j = pre_row[j]
                r_j1 = row[j-1]
                if pr_j >= r_j1:
                    row[j] = pr_j
                else:
                    row[j] = r_j1
        pre_row = row

    print(max_lcs)


if __name__ == '__main__':
    num = int(input())

    for _ in range(num):
        X = input().strip()
        Y = input().strip()

        result = calc_lcs4(X, Y)

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_10_C

最長共通部分列
"""


c = []
def prep_array(X, Y):
    global c
    """ 値が0の2次元配列を用意する。サイズは入力データの最大値を想定して縦横(1000+1)以上必要。 """
    # from array import array
    # c = [array('I', [0] * (len(X)+1)) for _ in range(len(Y)+1)]  #  arrayで用意
    c = [[0]*(len(Y)+2) for _ in range(len(X)+2)] #  リストで用意
    return c


def check_max(array):
    """ 2次元配列の中の最大の値を返す """
    max_lcs = 0
    for row in array:
        temp_max = max(row)
        if temp_max > max_lcs:
            max_lcs = temp_max
    return max_lcs


def calc_lcs4(X, Y, c):
    """
    Y[j]のアクセス方法を変更
    リストの値を一旦変数に保存するように変更
    最長共通部分長を関数内で計算するように変更
    4/5 のテストデータを使用してプロファイリングすると実効時間は 5.6秒
    """
    X = ' ' + X
    Y = ' ' + Y
    m = len(X)
    n = len(Y)
    max_lcs = 0

    pre_row = c[0]
    for i in range(1, m):
        row = c[i]
        XX = X[i]
        for j, YY in enumerate(Y):
            if XX == YY:
                pr_j1 = pre_row[j - 1]
                row[j] = pr_j1 + 1
                if pr_j1+1 > max_lcs:
                   max_lcs = pr_j1 + 1
            else:
                pr_j = pre_row[j]
                r_j1 = row[j-1]
                if pr_j >= r_j1:
                    row[j] = pr_j
                else:
                    row[j] = r_j1
        pre_row = row
    return max_lcs


if __name__ == '__main__':
    # データの入力
    num = int(input())
    #f = open('input.txt')
    #num = int(f.readline())

    for _ in range(num):
        X = input().strip()
        Y = input().strip()

        # 処理の実行
        result = calc_lcs4(X, Y, prep_array(X, Y))

        # 結果の表示
        print(result)
### BUGGY CODE ###

import copy

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

V=list(range(1,N+1))
K={v:set() for v in V}
L={v:None for v in V}
    
for i in range(M):
    v,w=map(int,input().split())

    K[v].add(w)
    K[w].add(v)


X=set()
Y={V[0]}

while X!=Y:
    Z=copy.deepcopy(Y-X)
    X=copy.deepcopy(Y)

    for v in Z:
        for n in K[v]:
            if n not in Y:
                Y.add(n)
                L[n]=v
                

if set(V)==X:
    print("Yes")
    for i in range(2,N+1):
        print(L[i])
else:
    print("No")


### FIXED CODE ###

import copy
import collections

#メイン部
N,M=map(int,input().split())

V=list(range(1,N+1))
H={v:set() for v in V}
L={v:None for v in V}

for i in range(M):
    v,w=map(int,input().split())
    H[v].add(w)
    H[w].add(v)

Q=collections.deque()
Q.append(V[0])

L[1]=1
n=1

while Q:
    x=Q.popleft()
    for v in H[x]:
        if L[v]!=None:
            continue
        L[v]=x
        n+=1
        Q.append(v)

if n==N:
    print("Yes")
    for i in range(2,N+1):
        print(L[i])
else:
    print("No")
### BUGGY CODE ###

n, m = tuple(map(int, input().split()))
h = list(map(int, input().split()))
ans = list(range(1, n+1))

for _ in range(m):
    a, b = tuple(map(int, input().split()))
    if h[a-1] > h[b-1]:
        if (b) in ans:
            ans.remove(b)
    elif h[a-1] < h[b-1]:
        if (a) in ans:
            ans.remove(a)
    else:
        if (a) in ans:
            ans.remove(a)
        if (b) in ans:
            ans.remove(b)

print(len(ans))


### FIXED CODE ###

n, m = tuple(map(int, input().split()))
h = list(map(int, input().split()))
ans = set([])

for _ in range(m):
    a, b = tuple(map(int, input().split()))
    if h[a-1] > h[b-1]:
        ans.add(b)
    elif h[a-1] < h[b-1]:
        ans.add(a)
    else:
        ans.add(a)
        ans.add(b)

print(n-len(ans))
### BUGGY CODE ###

n = int(input())
L = list(map(int, input().split()))
L.sort()

def binary_s(left, right, a, b):
    result = 0
    while L[a]+L[b] > L[left]:
        if right - left <= 1:
            if L[a]+L[b] > L[right]:
                result = right - max(a, b)
            else:
                result = left - max(a, b)
            break
        mid = (left+right)//2
        if L[a]+L[b] > L[mid]:
            left = mid
        else:
            right = mid
    return result
counter = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        counter += binary_s(j+1, n-1, i, j)
print(counter)

### FIXED CODE ###

n = int(input())
l = list(map(int, input().split(' ')))
l.sort()
counter = 0
for i in range(n):
    s = i + 2
    for j in range(i+1,n):        
        while (s < n and l[i] + l[j] > l[s]):
            s += 1
        counter += s-j-1
print(counter)
### BUGGY CODE ###

n = int(input())
p = list(map(int, input().split()))
ans = 1
for i in range(1, n):
    if p[i] <= min(p[:i]):
        ans += 1

print(ans)


### FIXED CODE ###

import numpy as np
n = int(input())
p = np.array(list(map(int, input().split())))
ans = 1
min_n = p[0]
for i in range(1, n):
    min_n = min(min_n, p[i-1])
    if p[i] <= min_n:
        ans += 1
print(ans)
### BUGGY CODE ###


Q=int(input())
LR=[]
L,R=0,0
for i in range(Q):
    l,r=map(int,input().split())
    L,R=max(L,l),max(R,r)
    LR.append([l,r])
M=R+1
lst=[0 for i in range(M)]

numlst=set([i for i in range(2,M)])
sosuulst=[]
a=2
while numlst:
    while not a in numlst:
        a+=1
    numlst.remove(a)
    if a:
        sosuulst.append(a)
    numLst=list(numlst)
    for i in numLst:
        if i%a==0:
            numlst.remove(i)

sosuulst=set(sosuulst)

count=0
for i in range(2,M):
    if i in sosuulst and (i+1)//2 in sosuulst:
        count+=1
    lst[i]=count

for l,r in LR:
    print(lst[r]-lst[max(l-2,0)])


### FIXED CODE ###


Q=int(input())
LR=[]
L,R=0,0
for i in range(Q):
    l,r=map(int,input().split())
    L,R=max(L,l),max(R,r)
    LR.append([l,r])
M=R+1
lst=[0 for i in range(M)]
sosuu=set([2])
count=0
for i in range(3,M//2+1,2):
    flag=0
    for m in sosuu:
        if i%m==0:
            flag=1
            break

    if not flag:
        sosuu.add(i)
        if (i+1)//2 in sosuu:
            count+=1
    lst[i]=count

A=M//2
if not (M//2)%2:
    A-=1

while lst[A]:
    A+=2
#print(A,"A",sosuu,count)
for i in range(A,M,2):
    if (i+1)//2 in sosuu:
        flag=0
        for m in sosuu:
            if i%m==0:
                flag=1
                break
        if not flag:
            sosuu.add(i)
            count+=1
    lst[i]=count
#print(lst)
for l,r in LR:
    print(lst[r]-lst[max(l-2,0)])
### BUGGY CODE ###

def open(box, key):
    n = 0
    for i in range(N):
        if (box>>i & 1) - (key>>i & 1) >= 1:
            n += 2**i
    return n
N, M = map(int, input().split())
INF = 10**10
dp = [[INF]*2**(N+1) for i in range(M+1)]
for i in range(M+1):
    dp[i][0] = 0
key = []
for i in range(M):
    a, b= map(int, input().split())
    n = 0
    c = list(map(int, input().split()))
    for i in range(b):
        n += 2**(c[i]-1)
    key.append((a,n)) 
for i in range(1,M+1):
    for j in range(2**(N+1)):
        dp[i][j] = min(dp[i-1][j], dp[i-1][open(j, key[i-1][1])]+key[i-1][0])
if dp[M-1][2**(N+1)-1] == INF:
    dp[M-1][2**(N+1)-1] = -1
print(dp[M-1][2**(N+1)-1])

### FIXED CODE ###

def open(box, key):
    return (box & (2**N-1 - key))
N, M = map(int, input().split())
INF = 10**8+1
dp = [[INF]*2**N for i in range(M+1)]
for i in range(M+1):
    dp[i][0] = 0
key = []
for i in range(M):
    a, b= map(int, input().split())
    n = 0
    c = list(map(int, input().split()))
    for i in range(b):
        n += 2**(c[i]-1)
    key.append((a,n))
for i in range(1,M+1):
    for j in range(2**N):
        dp[i][j] = min(dp[i-1][j], dp[i-1][open(j, key[i-1][1])]+key[i-1][0])
if dp[M-1][2**N-1] == INF:
    dp[M-1][2**N-1] = -1
print(dp[M-1][2**N-1])
### BUGGY CODE ###

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

ans = min(h)
h_ = [n - ans for n in h] + [0]
j = -1
while max(h_) > 0:
    for i, n in enumerate(h_):
        if n == 0:
            if (j + 1) < i:
                m = min(h_[j+1:i])
                ans += m
                for k in range(j+1, i):
                    h_[k] = h_[k] - m
            j = i
    #print(h_)

print(ans)

### FIXED CODE ###

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

ans = min(h)
h_ = [n - ans for n in h] + [0]
while max(h_) > 0:
    j = -1
    for i, n in enumerate(h_):
        if n == 0:
            if (j + 1) < i:
                m = min(h_[j+1:i])
                ans += m
                for k in range(j+1, i):
                    h_[k] = h_[k] - m
            j = i

print(ans)