CodeEff/ECCO huggingface dataset:
# Original solution
import bisect
n=int(eval(input()))
a=sorted([int(i) for i in input().split()])

ma=0
for i in range(10**5):
    ma=max(bisect.bisect_right(a,i+1)-bisect.bisect_left(a,i-1),ma)
print(ma)


# Optimized solution
import bisect
n=int(eval(input()))
a=[int(i) for i in input().split()]
b=[0]*(10**5)
for i in range(n):
    b[a[i]]+=1
ma=0
for i in range(1,10**5-1):
    ma=max(b[i-1]+b[i]+b[i+1],ma)
print(ma)
#累積和でやると早い
# Original solution
from collections import Counter, deque
# from copy import copy, deepcopy
# from fractions import gcd
# from functools import reduce
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline

def resolve():
    N=int(eval(input()))
    A=list(map(int,input().split()))
    AA=Counter(A)
    maxval=0
    for i in list(AA.keys()):
        maxval=max(AA[i-1]+AA[i]+AA[i+1],maxval)

    print(maxval)



resolve()

# Optimized solution
from collections import Counter, deque
# from copy import copy, deepcopy
# from fractions import gcd
# from functools import reduce
# from itertools import accumulate, permutations, combinations, combinations_with_replacement, groupby, product
# import math
# import numpy as np
# from operator import xor
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline

def resolve():

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

    AA=Counter(A)

    ans=0
    if N==1:
        print((1))
    elif N==2:
        if abs(A[0]-A[1])<=1:
            print((2))
        else:
            print((1))
    else:
        for i in range(N-2):
            ans=max(AA[i]+AA[i+1]+AA[i+2],ans)
        print(ans)

resolve()
# Original solution
A1,A2,A3=list(map(int,input().split()))
A=[A1,A2,A3]
A.append(A1)
def A_(i):
    if A[i]-A[i+1]>=0:
        return A[i]-A[i+1]
    else:
        return A[i+1]-A[i]
B=[A_(i) for i in range(3)]
B.append(A_(0))
B.append(A_(1))
def sum(j):
    return B[j]+B[j+1]
C=[sum(j) for j in range(3)]
print((min(C)))

# Optimized solution
A1,A2,A3=list(map(int,input().split()))
A_1=abs(A1-A2)+abs(A2-A3)
A_2=abs(A1-A3)+abs(A2-A3)
A_3=abs(A1-A2)+abs(A1-A3)
print((min(A_1,A_2,A_3)))
# Original solution
array = sorted([int(x) for x in input().split()])

tmp = array[0]
ans = 0
for i in array[1:]:
    ans += i-tmp
    tmp = i
print(ans)

# Optimized solution
a, a2, a3 = sorted([int(x) for x in input().split()])
print((abs(a2-a)+abs(a3-a2)))
# Original solution
a = list(map(int, input().split()))
r = max(a)
a.remove(max(a))
ans = 0
ans += abs(r - max(a)) + abs(a[0] - a[1])
print(ans)


# Optimized solution
a, b, c = list(map(int, input().split()))
l = [a ,b, c]
l.sort()
ans = []
p = l.pop()
ans.append(abs(p-l[0]) + abs(l[0]-l[1]))
ans.append(abs(p-l[1]) + abs(l[1]-l[0]))
print((min(ans)))
# Original solution
a1,a2,a3 = list(map(int,input().split(" ")))


a12 = abs(a1 - a2)
a13 = abs(a1 - a3)
a23 = abs(a2 - a3)

max_num = max(a12,a13, a23)

print((a12 + a13 + a23 - max_num))



# Optimized solution
a_lst = list(map(abs, list(map(int, input().split(" ")))))

a_lst.sort()

total = 0
previous = a_lst[0]
for i in a_lst[1:]:
    total += (i - previous)
    previous = i

print(total)
# Original solution
A1, A2, A3 = list(map(int, input().split()))
ans = 1000
for x in range(6):
    temp = 0
    if x == 0:
        temp += abs(A2 - A1)
        temp += abs(A3 - A2)
    elif x == 1:
        temp += abs(A3 - A1)
        temp += abs(A2 - A3)
    elif x == 2:
        temp += abs(A1 - A2)
        temp += abs(A3 - A1)
    elif x == 3:
        temp += abs(A3 - A2)
        temp += abs(A1 - A3)
    elif x == 4:
        temp += abs(A1 - A3)
        temp += abs(A2 - A1)
    elif x == 5:
        temp += abs(A2 - A3)
        temp += abs(A1 - A2)
    
    if temp < ans :
        ans = temp
print(ans)

# Optimized solution
a,b,c = sorted(map(int, input().split()))
print((c-a))
# Original solution
a,b,c = list(map(int,input().split()))
print((max(a,b,c)-min(a,b,c)))

# Optimized solution
t = list(map(int,input().split()))
print((max(t)-min(t)))
# Original solution
a, b, c =sorted(map(int, input().split()), reverse=True)
print(((a-b)+(b-c)))

# Optimized solution
a = list(map(int, input().split()))
a.sort()
print((abs(a[2]-a[1])+abs(a[1]-a[0])))
# Original solution
a = list(map(int, input().split()))
a.sort()
print((a[2]-a[1]+a[1]-a[0]))


# Optimized solution
a, b, c = sorted(map(int, input().split()))
print((c-a))
# Original solution
X = list(map(int,input().split()))
X.sort()
print((X[1]-X[0] + X[2]-X[1]))

# Optimized solution
X = list(map(int,input().split()))
print((max(X)-min(X)))
# Original solution
a = sorted(list(map(int,input().split())))
print((a[2] - a[0]))

# Optimized solution
a = list(map(int,input().split()))
print((max(a) - min(a)))
# Original solution
A = list(map(int,input().split()))
A.sort()
ans = A[2]-A[1] + A[1]-A[0]
print(ans)

# Optimized solution
A = list(map(int,input().split()))
A.sort()
ans = A[2]-A[0]
print(ans)
# Original solution
A = [int(i) for i in input().split()]

ans = 0

A.sort()

for i in range(len(A)-1):
    ans += A[i+1] - A[i]

print(ans)

# Optimized solution
A = [int(i) for i in input().split()]

print((max(A)-min(A)))
# Original solution
A,B,C=list(map(int,input().split()))
l_list=[A,B,C]
l_list.sort()
print((int(l_list[2])-(l_list[0])))

# Optimized solution
a,b,c=sorted(map(int,input().split()))
print((abs(a-b)+abs(b-c)))
# Original solution
n = list(map(int, input().split()))
n.sort()
print((n[2]-n[0]))


# Optimized solution
n = [int(i) for i in input().split()]
n.sort()
print((int(n[2]-n[0])))
# Original solution
# -*- coding: utf-8 -*-
import sys
import itertools

# 標準入力を取得
A = list(map(int, input().split()))

# 求解処理
ans = sys.maxsize
for A_1, A_2, A_3 in itertools.permutations(A, r=3):
    ans = min(ans, abs(A_2 - A_1) + abs(A_3 - A_2))

# 結果出力
print(ans)


# Optimized solution
# -*- coding: utf-8 -*-
# 標準入力を取得
A = list(map(int, input().split()))

# 求解処理
ans = max(A) - min(A)

# 結果出力
print(ans)
# Original solution
A123 = list(map(int, input().split()))
ans = 1000

for i, a in enumerate(A123):
    for j, b in enumerate(A123):
        for k, c in enumerate(A123):
            if i != j and j != k and k != i:
                tmp = abs(b - a) + abs(c - b)
                if tmp < ans:
                    ans = tmp

print(ans)

# Optimized solution
A1, A2, A3 = list(map(int, input().split()))
ans = max(A1, A2, A3) - min(A1, A2, A3)

print(ans)
# Original solution
*a,=list(map(int,input().split()))
print((max(a)-min(a)))

# Optimized solution
A,B,C=sorted(map(int,input().split()))
print((C-A))
# Original solution
A = list(map(int,input().split()))
A.sort()
print((A[2] - A[0]))

# Optimized solution
A = sorted(list(map(int,input().split())))
print((A[2] - A[0]))
# Original solution
c = list(map(int,input().split()))
x = max(c)
c.remove(x)
y = max(c)
c.remove(y)
z = max(c)
c.remove(z)

print((x - z))

# Optimized solution
*a, = list(map(int,input().split()))
print((max(a)-min(a)))
# Original solution
A1, A2, A3 = sorted(map(int, input().split()))
print((A3-A1))

# Optimized solution
A = sorted(map(int, input().split()))
print((A[-1]-A[0]))
# Original solution
A=list(map(int,input().split()))
print((max(A)-min(A)))

# Optimized solution
A1,A2,A3=sorted(map(int,input().split()))
print((A3-A1))
# Original solution
A1, A2, A3 = list(map(int,input().split()))
if A1>A2>A3 or A3>A2>A1:
    x = abs(A1-A3)
    print(x)
elif A2>A1>A3 or A3>A1>A2:
    x = abs(A2-A3)
    print(x)
else:
    x = abs(A1-A2)
    print(x)

# Optimized solution
a = list(map(int,input().split()))
print((max(a) - min(a)))
# Original solution
a,b,c = sorted(map(int,input().split()))
print((c-b + b-a))

# Optimized solution
*a, = list(map(int,input().split()))
print((max(a)-min(a)))
# Original solution
def i1():
 return int(eval(input()))
def i2():
 return [int(i) for i in input().split()]
a=i2()
a.sort()
a=a[::-1]
print((a[0]-a[2]))

# Optimized solution
def i1():
 return int(eval(input()))
def i2():
 return [int(i) for i in input().split()]
a=i2()
b=[]
a.sort()
print((abs(a[0]-a[1])+abs(a[2]-a[1])))
# Original solution
a = sorted(list(map(int, input().split())), reverse=True)
res = 0
for i in range(3 - 1):
    res += a[i] - a[i + 1]
print(res)

# Optimized solution
a = list(map(int, input().split()))
a.sort()
print((a[-1] - a[0]))
# Original solution
a,_,b=sorted(map(int,input().split()));print((b-a))

# Optimized solution
*a,=list(map(int,input().split()));print((max(a)-min(a)))
# Original solution
li = list(map(int,input().split()))
li = sorted(li)
answer = -li[0]+li[2]
print(answer)

# Optimized solution
L = sorted(map(int, input().split()))
print((abs(L[0] - L[1]) + abs(L[1] - L[2])))
# Original solution
a=list(map(int,input().split()))
b=max(a)
c=min(a)
print((b-c))

# Optimized solution
a,b,c=list(map(int,input().split()))
d=max(a,b,c)
e=min(a,b,c)
print((d-e))
# Original solution
a = list(map(int, input().split()))
a.sort()
cost = 0
for i in range(1, len(a)):
    cost += a[i] - a[i-1]
print(cost)


# Optimized solution
a = list(map(int, input().split()))
a.sort()
c = 0
for i in range(1, len(a)):
    c += abs(a[i] - a[i-1])
print(c)
# Original solution
a,b,c = input().split(' ')
A = abs(int(a)-int(b))
B = abs(int(b)-int(c))
C = abs(int(c)-int(a))
N = A + B + C -max(A, B, C)
print(N)

# Optimized solution
*a,= list(map(int, input().split( )))
print((max(*a)-min(*a)))
# Original solution
a,b,c = list(map(int,input().split()))
ans = 9999
ans = min(ans, abs(a-b) + abs(b-c), abs(a-c) + abs(c-b))
ans = min(ans, abs(b-a) + abs(a-c), abs(b-c) + abs(c-a))
ans = min(ans, abs(c-a) + abs(a-b), abs(c-b) + abs(b-a))
print(ans)

# Optimized solution
a,b,c = list(map(int,input().split()))
print((max(a,b,c) - min(a,b,c)))
# Original solution
A = list(map(int, input().split()))

A_sort = sorted(A)
print((abs(A_sort[1] - A_sort[0]) + (A_sort[2] - A_sort[1])))


# Optimized solution
a,b,c=sorted(map(int,input().split()))
print((c-a))
# Original solution
List = sorted([int(i) for i in input().split()])
print((List[2] - List[0]))

# Optimized solution
a1, a2, a3 = sorted(list(map(int, input().split())))
print((a3-a1))
# Original solution
a,b,c=list(map(int,input().split()))
d=[abs(a-b),abs(b-c),abs(c-a)]
print((sum(d)-max(d)))

# Optimized solution
l = list(map(int,input().split()))
print((max(l)-min(l)))
# Original solution
a,b,c = sorted(map(int,input().split()))

print(( c - a))

# Optimized solution
A = list(map(int, input().split()))
print((max(A)-min(A)))
# Original solution
# -*- coding: utf-8 -*-

list = list(map(int,input().split()))
list.sort()
sum = list[2]-list[1]+list[1]-list[0]

print(sum)


# Optimized solution
# -*- coding: utf-8 -*-

list = list(map(int,input().split()))
list.sort()
sum = list[2]-list[0]

print(sum)
# Original solution
a = list(map(int,input().split()))
ti = min(a)
da = max(a)
print((da-ti))

# Optimized solution
a = list(map(int,input().split()))
ti = min(a)
da = max(a)
print((int(da-ti)))
# Original solution
A, B, C = sorted(map(int,input().split()))
print((abs(B-C)+abs(A-B)))

# Optimized solution
A, B, C = sorted(map(int,input().split()))
print((abs(C - B) + abs(B - A)))
# Original solution
a, b, c = sorted(map(int,input().split()))
print((b-a+c-b))

# Optimized solution
A, B, C = sorted(map(int,input().split()))
print((C-B+B-A))
# Original solution
a=list(map(int,input().split()))
a.sort()
ans=0 if len(set(a))==1 else a[2]-a[0]
print(ans)  

# Optimized solution
a = [int(x) for x in input().split()]
print((max(a) - min(a)))
# Original solution
a, b, c = sorted(map(int, input().split()))
print((c - a))


# Optimized solution
a, b, c = list(map(int, input().split()))
print((max(a, b, c) - min(a, b, c)))
# Original solution
l=sorted(list(map(int,input().split())))
print((l[2]-l[0]))

# Optimized solution
l=sorted(list(map(int,input().split())))
print((max(l)-min(l)))
# Original solution
A=list(map(int,input().split()))
A.sort()
print((A[2]-A[0]))


# Optimized solution
A=list(map(int,input().split()))
print((max(A)-min(A)))
# Original solution
n=10000000
p=[1]*(n+1)
p[0],p[1]=0,0
for i in range(2,int(n**0.5)+1):
    if p[i]:        
        for j in range(i*i,n+1,i):
            p[j]=0
#p=[i for i in range(n+1) if p[i]==1]
while 1:
    n=int(eval(input()))
    if n==0: break
    for i in range(n,2,-1):
        if (p[i],p[i-2],p[i-6],p[i-8])==(1,1,1,1):
            print(i)
            break

# Optimized solution
n=10000000
p=[1]*(n+1)
p[0],p[1]=0,0
for i in range(2,int(n**0.5)+1):
    if p[i]:        
        for j in range(i*i,n+1,i):
            p[j]=0
#p=[i for i in range(n+1) if p[i]==1]
while 1:
    n=int(eval(input()))
    if n==0: break
    if n<19:print((13))
    else:
        for i in range((n+1)//10*10-1,2,-10):
            if (p[i],p[i-2],p[i-6],p[i-8])==(1,1,1,1):
                print(i)
                break
# Original solution
primes = [0, 0] + [1] * 9999999
for i in range(2, 3163):
    if primes[i]:
        for j in range(i*i, 10000001, i):
            primes[j] = 0

while True:
    n = int(eval(input()))
    if n == 0:
        break
    while not (primes[n-8] & primes[n-6] & primes[n-2] & primes[n]):
        n -= 1
    print(n)

# Optimized solution
primes = [0, 0] + [1] * 9999999
for i in range(2, 3163):
    if primes[i]:
        for j in range(i*i, 10000001, i):
            primes[j] = 0

while True:
    n = int(eval(input()))
    if n == 0:
        break
    for i in range(5, n+1)[::-1]:
        if primes[i-8] & primes[i-6] & primes[i-2] & primes[i]:
            print(i)
            break
# Original solution
def isP(n):
	for i in prime:
		if i >= n:
			break
		if n%i == 0:
			return False
	return True
		
r = int(10000001**0.5)
s = int(r**0.5)
p = [1]*r
p[0] = p[1] = 0
for i in range(2,s):
	if p[i]:
		p[2*i::i] = [0 for x in range(2*i,r,i)]
prime = []
for i in range(r):
	if p[i]:
		prime.append(i)

while 1:
	n = eval(input())
	if n == 0: break
	for i in range(n-(1-n%2),10,-2):
		if isP(i) and isP(i-2) and isP(i-6) and isP(i-8):
			print(i)
			break

# Optimized solution
def isP(n):
	for i in prime:
		if i >= n:
			break
		if n%i == 0:
			return False
	return True

r = int(10000001**0.5)
s = int(r**0.5)
p = [1]*r
p[0] = p[1] = 0
for i in range(2,s):
	if p[i]:
		p[2*i::i] = [0 for x in range(2*i,r,i)]
prime = []
for i in range(r):
	if p[i]:
		prime.append(i)

while 1:
	try:
		n = eval(input())
		if n == 0: break
		i = n-(1-n%2)
		while i > 12:
			p6 = isP(i-6)
			if not isP(i-8) or not isP(i-2):
				if not p6:
					i -= 10
				else:
					i -= 4
				continue
			if isP(i) and p6:
				print(i)
				break
			i -= 2
	except:
		pass
# Original solution
def isP(n):
	for i in prime:
		if i >= n:
			break
		if n%i == 0:
			return False
	return True

r = int(10000001**0.5)
s = int(r**0.5)
p = [1]*r
p[0] = p[1] = 0
for i in range(2,s):
	if p[i]:
		p[2*i::i] = [0 for x in range(2*i,r,i)]
prime = []
for i in range(r):
	if p[i]:
		prime.append(i)

while 1:
	try:
		n = eval(input())
		if n == 0: break
		i = n-(1-n%2)
		while i > 12:
			p6 = isP(i-6)
			if not isP(i-8) or not isP(i-2):
				if not p6:
					i -= 10
				else:
					i -= 4
				continue
			if isP(i) and p6:
				print(i)
				break
			i -= 2
	except:
		pass

# Optimized solution
def isP(n):
	for i in prime:
		if i >= n:
			break
		if n%i == 0:
			return False
	return True

r = int(10000001**0.5)
s = int(r**0.5)
p = [1]*r
p[0] = p[1] = 0
for i in range(2,s):
	if p[i]:
		p[2*i::i] = [0 for x in range(2*i,r,i)]
prime = []
for i in range(r):
	if p[i]:
		prime.append(i)

while 1:
	try:
		n = eval(input())
		if n == 0: break
		i = n-(1-n%2)
		while i > 12:
			p6 = isP(i-6)
			if not isP(i-8) or not isP(i-2):
				if not p6:
					i -= 10
				else:
					i -= 4
				continue
			if isP(i) and p6:
				print(i)
				break
			i -= 2
	except:
		break
# Original solution
r =10000001
p = [1]*r
p[0]= p[1] = 0
for i in range(int(r**0.5)):
	if p[i]:
		p[2*i::i] = [0 for j in range(2*i,r,i)]
		
while 1:
	try:
		n = eval(input())
		if n == 0: break
		n -= 1-n%2
		while any(not p[n-i] for i in [0,2,6,8]):
			n -= 2
		print(n)
	except:
		pass

# Optimized solution
r =10000001
p = [1]*r
p[0]= p[1] = 0
for i in range(int(r**0.5)):
	if p[i]:
		p[2*i::i] = [0 for j in range(2*i,r,i)]
		
while 1:
	try:
		n = eval(input())
		if n == 0: break
		n -= 1-n%2
		while any(not p[n-i] for i in [0,2,6,8]):
			n -= 2 + (2 + 4*(1-p[n-6]))*(1-p[n-2])
		print(n)
	except:
		pass
# Original solution
r =10000001
p = [1]*r
p[0]= p[1] = 0
for i in range(int(r**0.5)):
	if p[i]:
		p[2*i::i] = [0 for j in range(2*i,r,i)]
		
while 1:
	try:
		n = eval(input())
		if n == 0: break
		n -= 1-n%2
		while any(not p[n-i] for i in [0,2,6,8]):
			n -= 2 + (2 + 4*(1-p[n-6]))*(1-p[n-2])
		print(n)
	except:
		pass

# Optimized solution
ref = [[[10,8],[4,4]],[[10,2],[4,2]]]
r =10000001
p = [1]*r
p[0]= p[1] = 0
for i in range(int(r**0.5)):
	if p[i]:
		p[2*i::i] = [0 for j in range(2*i,r,i)]
		
while 1:
	try:
		n = eval(input())
		if n == 0: break
		n -= 1-n%2
		while any(not p[n-i] for i in [0,2,6,8]):
			n -= ref[p[n-2]][p[n-6]][p[n-8]]
		print(n)
	except:
		pass
# Original solution
ref = [[[10,8],[4,4]],[[10,2],[4,2]]]
r =10000001
p = [1]*r
p[0]= p[1] = 0
for i in range(int(r**0.5)):
	if p[i]:
		p[2*i::i] = [0 for j in range(2*i,r,i)]
		
while 1:
	try:
		n = eval(input())
		if n == 0: break
		n -= 1-n%2
		while any(not p[n-i] for i in [0,2,6,8]):
			n -= ref[p[n-2]][p[n-6]][p[n-8]]
		print(n)
	except:
		pass

# Optimized solution
ref = [[[10,8],[4,4]],[[10,2],[4,2]]]
r =10000001
p = [1]*r
p[0]= p[1] = 0
for i in range(int(r**0.5)):
	if p[i]:
		p[2*i::i] = [0]*len(p[2*i::i])
		
while 1:
	try:
		n = eval(input())
		if n == 0: break
		n -= 1-n%2
		while any(not p[n-i] for i in [0,2,6,8]):
			n -= ref[p[n-2]][p[n-6]][p[n-8]]
		print(n)
	except:
		pass
# Original solution
import sys
sys.setrecursionlimit(10**7)

n,q=list(map(int,input().split()))
abcd=[list(map(int,input().split())) for _ in range(n-1)]
xyuv=[list(map(int,input().split())) for _ in range(q)]
g=[[] for _ in range(n)]
for a,b,c,d in abcd:
  a,b=a-1,b-1
  g[a].append((b,c,d))
  g[b].append((a,c,d))
# LCAを求める。自作する。
# 頂点0を根としたときの頂点iの親
par=[i for i in range(n)]
# 各頂点の深さ。根は深さ0
depth=[0]*n
tour=[]

colorsum=[[] for _ in range(n)]
colornum=[[] for _ in range(n)]
colorsum[0]=[0]*n
colornum[0]=[0]*n
dist=[0]*n
tmpnum,tmpsum=[0]*n,[0]*n
def et(p,v,tour):
  for nv,c,d in g[v]:
    if nv==p:continue
    tour.append((nv,c,d))
    depth[nv]=depth[v]+1
    par[nv]=v
    tmpnum[c]+=1
    tmpsum[c]+=d
    colornum[nv]=tmpnum.copy()
    colorsum[nv]=tmpsum.copy()
    dist[nv]=sum(tmpsum)
    tour=et(v,nv,tour)
    tmpnum[c]-=1
    tmpsum[c]-=d
    tour.append((nv,c,-d))
  return tour
tour.append((0,None,None))
tour=et(-1,0,tour)
def lca(u,v):
  if depth[v]<depth[u]:u,v=v,u
  while u!=v:
    if depth[v]<depth[u]:u,v=v,u
    v=par[v]
  return v
for x,y,u,v in xyuv:
  u,v=u-1,v-1
  w=lca(u,v)
  uvlen=dist[u]+dist[v]-dist[w]*2
  uvsum=colorsum[u][x]+colorsum[v][x]-colorsum[w][x]*2
  uvnum=colornum[u][x]+colornum[v][x]-colornum[w][x]*2
  print((uvlen-uvsum+uvnum*y))



# Optimized solution
import sys
sys.setrecursionlimit(10**7)

n,q=list(map(int,input().split()))
abcd=[list(map(int,input().split())) for _ in range(n-1)]
xyuv=[list(map(int,input().split())) for _ in range(q)]
g=[[] for _ in range(n)]
for a,b,c,d in abcd:
  a,b=a-1,b-1
  g[a].append((b,c,d))
  g[b].append((a,c,d))
# LCAを求める。自作する。
# 頂点0を根としたときの頂点iの親
par=[i for i in range(n)]
# 各頂点の深さ。根は深さ0
depth=[0]*n
tour=[]
hatsu=[0]*n
dist=[0]*n
tmp=0
def et(p,v,tour):
  global tmp
  for nv,c,d in g[v]:
    if nv==p:continue
    hatsu[nv]=len(tour)
    tour.append((nv,c,d))
    depth[nv]=depth[v]+1
    par[nv]=v
    tmp+=d
    dist[nv]=tmp
    tour=et(v,nv,tour)
    tmp-=d
    tour.append((nv,c,-d))
  return tour
tour.append((0,None,None))
tour=et(-1,0,tour)
def lca(u,v):
  if depth[v]<depth[u]:u,v=v,u
  while u!=v:
    if depth[v]<depth[u]:u,v=v,u
    v=par[v]
  return v
dc={}
dcary={}
for i,(v,c,d) in enumerate(tour):
  if c in dc:
    ci=1 if d>0 else -1
    dc[c].append((dc[c][-1][0]+ci,dc[c][-1][1]+d))
    dcary[c].append(i)
  else:
    dc[c]=[(0,0),(1,d)]
    dcary[c]=[0,i]
from bisect import bisect_right as bl
for x,y,u,v in xyuv:
  u,v=u-1,v-1
  w=lca(u,v)
  uvlen=dist[u]+dist[v]-dist[w]*2
  if x not in dc:
    print(uvlen)
    continue
  widx=bl(dcary[x],hatsu[w])-1
  wnum,wsum=dc[x][widx]
  uidx=bl(dcary[x],hatsu[u])-1
  vidx=bl(dcary[x],hatsu[v])-1
  unum,usum=dc[x][uidx]
  vnum,vsum=dc[x][vidx]
  uvsum=usum+vsum-wsum*2
  uvnum=unum+vnum-wnum*2
  #print(uvlen-uvsum+uvnum*y,uvlen,usum,vsum,wsum,uvnum)
  print((uvlen-uvsum+uvnum*y))
exit()
for k in dc:
  print(('=====',k,'====='))
  print((dcary[k]))
  print((dc[k]))
print(hatsu)
# Original solution
import sys
input=sys.stdin.readline

# 整数 n を m 進数 k 桁で表現した文字列
# ex. bins(3,2,2) => 11
def bins(n, m, k):
    # n がマイナスだったり、k桁で収まらない場合やばそう
    s = ""
    while n > 0:
        s = str(n%m) + s
        n //= m
    s = "0"*(k-len(s)) + s
    return s

def main():
    s = input().strip()
    n = len(s)-1 # s の各文字（"+" を入れるスキマ）の数
    ans = 0
    # s の各文字の間に "+" を挿入する・しない場合の
    # 全ての文字列 (2**n 通り) を作って計算する
    for i in range(2**n):
        b = bins(i,2,n)
        t = s[0]
        for j in range(n):
            if b[j] == "1":
                t += "+"
            t += s[j+1]
        ans += eval(t)
    print(ans)

if __name__ == '__main__':
    main()


# Optimized solution
import sys
input=sys.stdin.readline

def main():
    s = input().strip()
    n = len(s)-1
    ans = 0
    for i in range(1<<n):
        t = s[0]
        for j in range(n):
            if ((i >> j) & 1) == 1:
                t += "+"
            t += s[j+1]
        ans += eval(t)
    print(ans)

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

s = list(sys.stdin.readline().rstrip())
l = len(s)

def main():
    res = 0
    cand = list(range(1, l))
    for inser_cnt in range(l):
        for idces in combinations(cand, inser_cnt):
            t = s.copy()
            idces = list(idces)
            for i in idces[::-1]:
                t.insert(i, '+')
            res += eval(''.join(t))
            
    return res
                     
if __name__ == '__main__':
    ans = main()
    print(ans)

# Optimized solution
import sys

s = sys.stdin.readline().rstrip()
n = len(s)

def c(n):
    return pow(2, max(0, n - 1))
  
def main():
    res = 0
    for l in range(n):
        for r in range(l, n):
            res += int(s[l:r+1]) * c(l) * c(n - 1 - r)
    print(res)

if __name__ ==  '__main__':
    main()
# Original solution
import sys

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

def solve():
    S = input()
    N = len(S) - 1
    ans = 0

    for i in range(2**N):
        bi = bin(i)[2:].zfill(N)
        # print(bi)
        ans += calc(S, bi)

    print(ans)

def calc(S, bi):
    ret = 0
    k = 0

    for i in range(len(S)):
        if i == 0:
            continue
        else:
            if bi[i-1] == '1':
                ret += int(S[k:i])
                k = i

    ret += int(S[k:])

    return ret

if __name__ == '__main__':
    solve()


# Optimized solution
import sys
from itertools import accumulate

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

def solve():
    S = [int(i) for i in input()]
    N = len(S)
    sac = [0] + list(accumulate(S))
    ans = 0

    for i in range(N):
        ans += (int(sac[i] * 2**(i - 1)) + 2**i * S[i]) * 10**(N - 1 - i)

    print(ans)

if __name__ == '__main__':
    solve()
# Original solution
S = str(eval(input()))

ans = 0
N = len(S)
for i in range(2**N):
  pattern = bin(i)[2:].zfill(N)
  formula = ''
  for j in range(N):
    mark = ''
    if pattern[j] == '1' and j < N-1:
      mark = '+'
    formula += S[j]+mark
  ans += eval(formula)

print((ans//2))

# Optimized solution
S = str(eval(input()))

ans = 0
N = len(S)

for i in range(2**(N-1)):
  pattern = bin(i)[2:].zfill((N-1))
  formula = ''
  for j in range(N):
    mark = ''
    if j < N-1:
      if pattern[j] == '1':
        mark = '+'
    formula += S[j]+mark
  ans += eval(formula)

print(ans)