CodeEff/ECCO huggingface dataset:
# Original solution
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, acos, asin, atan, sqrt, tan, cos, pi
from operator import mul
from functools import reduce
from pprint import pprint


sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 998244353


n = I()
A = LI()
D = Counter(A)
min_a = min(A)
max_a = min_a * 2 if D[min_a] == 1 else min_a * 2 - 1
if D[min_a] > 2:
    print("Impossible")
    exit()
flg = 0
for i in range(min_a + 1, max_a + 1):
    if D[i] < 2:
        print("Impossible")
        exit()
    D[i] -= 2

for k in list(D.keys()):
    if k > max_a:
        print("Impossible")
        exit()

print("Possible")



















# Optimized solution
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, acos, asin, atan, sqrt, tan, cos, pi
from operator import mul
from functools import reduce
from pprint import pprint


sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 998244353


n = I()
A = LI()
D = Counter(A)
min_a = min(A)
max_a = min_a * 2 if D[min_a] == 1 else min_a * 2 - 1
if D[min_a] > 2 or max(A) > max_a:
    print("Impossible")
    exit()

for i in range(min_a + 1, max_a + 1):
    if D[i] < 2:
        print("Impossible")
        exit()

print("Possible")
# Original solution
# cf16-exhibition-final-openC - Cheating Nim
import sys
input = sys.stdin.readline

from functools import reduce
from operator import xor


def main():
    # player is second move -> make xor 0
    N = int(eval(input()))
    A = sorted(map(int, [eval(input()) for _ in range(N)]), reverse=1)
    ans, x = 0, reduce(xor, A)
    # cand := rightmost bits of i^i-1
    cand = set(bin(i ^ i - 1)[::-1].rfind("1") for i in A)
    for i in range(29, -1, -1):
        p = 2 ** i
        if x & p:  # i-th bit is on
            if i in cand:  # possible to erase i-th bit of x
                x ^= (p - 1)
                ans += 1
            else:
                print((-1))
                return
    print(ans)


if __name__ == "__main__":
    main()

# Optimized solution
# cf16-exhibition-final-openC - Cheating Nim
import sys
input = sys.stdin.readline


def main():
    # player is second move -> make xor 0
    N = int(eval(input()))
    A = sorted(map(int, [eval(input()) for _ in range(N)]), reverse=1)
    ans, x, flg = 0, 0, [0] * 30
    for i in A:
        x ^= i
        p = bin(i ^ i - 1)[::-1].rfind("1")
        flg[p] = 1
    for i in range(29, -1, -1):
        p = 2 ** i
        if x & p:  # i-th bit is on
            if flg[i]:  # possible to erase i-th bit of x
                x ^= p - 1
                ans += 1
            else:
                print((-1))
                return
    print(ans)


if __name__ == "__main__":
    main()
# Original solution
N,*A=list(map(int,open(0)))
x=0
B=[]
for a in A:
	x^=a
	B+=a^a-1,
z=0
k=2**30
for b in sorted(set(B))[::-1]:
	while not(x&k):
		k//=2
	if b&k:
		x^=b
		z+=1
print((-1if x else z))

# Optimized solution
N,*A=list(map(int,open(0)))
x=0
B=[]
for a in A:
	x^=a
	B+=a^a-1,
z=0
k=2**30
for b in sorted(B)[::-1]:
	while k and not(x&k):
		k//=2
	if b&k and b<2*k:
		x^=b
		z+=1
print((-1if x else z))
# Original solution
from functools import reduce
from operator import xor

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

x = reduce(xor, A)

ans = 0
K = x.bit_length()
for k in reversed(list(range(K))):
    if (x >> k) & 1:
        for a in A:
            t = a ^ (a - 1)
            if t == 2 ** (k + 1) - 1:
                x ^= t
                ans += 1
                break

if x == 0:
    print(ans)
else:
    print((-1))

# Optimized solution
from functools import reduce
from operator import xor

N, *A = list(map(int, open(0).read().split()))
x = reduce(xor, A)

memo = set(a ^ (a - 1) for a in A)

ans = 0
K = x.bit_length()
for k in reversed(list(range(K))):
    if (x >> k) & 1:
        t = (2 << k) - 1
        if t in memo:
            x ^= t
            ans += 1

if x == 0:
    print(ans)
else:
    print((-1))
# Original solution
import itertools
from functools import reduce
from operator import mul

N = int(eval(input()))
# a, b, x = map(lambda i: int(i), input().split(' '))

def main():
    # hen1 = a / 2
    # hen2 = b - (x / (a * a))
    # print(math.degrees(math.atan(hen2 / hen1)))
    primes = prime_factorize(N)
    if len(primes) == 1:
        print((primes[0] - 1))
        return
    elif len(primes) == 2:
        print((primes[0] + primes[1] - 2))
        return

    min = -1
    for i in range(1, len(primes) + 1):
        for v in itertools.combinations(primes, i):
            a = reduce(mul, list(v))
            b = N // a
            if min == -1 or min > (a + b - 2):
                min = a + b - 2
    print(min)

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

main()


# Optimized solution
import math

N = int(eval(input()))
# a, b, x = map(lambda i: int(i), input().split(' '))

def main():
    root_n = math.sqrt(N)
    answer = -1
    for a in range(1, int(root_n) + 1):
        if N % a == 0:
            b = N // a
            v = a + b - 2
            if answer == -1 or answer > v:
                answer = v
    print(v)

main()
# Original solution
def main():
    N = int(eval(input()))
    i = 2
    ans = N + 1
    while i ** 2 <= N:
        if N % i == 0:
            ans = min(i + N / i, ans)
        i += 1
    print((int(ans - 2)))


if __name__ == '__main__':
    main()

# Optimized solution
def main():
    n = int(eval(input()))
    f = []
    i = 2
    while i * i <= n:
        if n % i == 0:
            f.append(i)
            if i * i != n:
                f.append(n // i)
        i += 1
    if n != 1:
        f.append(n)
    f.sort()
    answer = float("inf")
    for ff in f:
        answer = min(answer, ff + n // ff - 2)
    print(answer)


if __name__ == '__main__':
    main()
# Original solution
N = int(eval(input()))
root = int(N**0.5)

pairs = [[i, N //i] for i in range(1, root+1) if N % i == 0]

move = min([pair[0] + pair[1] -2 for pair in pairs])
print(move)

# Optimized solution
N = int(eval(input()))
root = int(N**0.5)
print((min([i + N // i -2 for i in range(1, root+1) if N % i == 0])))
# Original solution
n = int(eval(input()))
i = int(n**(1/2))
while n%i:
	i-=1
j = n//i
ans = (i - 1) + (j - 1)
#print(i,j)
print(ans)

# Optimized solution
n = int(eval(input()))
for i in range(1,int(n**(1/2)+1))[::-1]:
    if not n%i:
        j = n//i 
        print((i-1+j-1))
        break
# Original solution
def solve(string):
    n = int(string)
    l = int(n**0.5)
    while n % l > 0:
        l -= 1
    return str(l + n // l - 2)


if __name__ == '__main__':
    print((solve(eval(input()))))


# Optimized solution
def solve(string):
    n = int(string)
    for i in range(int(n**0.5) + 1, 0, -1):
        if n % i:
            continue
        else:
            return str(i + n // i - 2)


if __name__ == '__main__':
    print((solve(eval(input()))))
# Original solution
def solve(string):
    n = int(string)
    for i in range(int(n**0.5) + 1, 0, -1):
        if n % i == 0:
            return str(i + n // i - 2)


if __name__ == '__main__':
    print((solve(eval(input()))))


# Optimized solution
def solve(string):
    n = int(string)
    for i in range(int(n**0.5) + 1, 0, -1):
        if not n % i:
            return str(i + n // i - 2)


if __name__ == '__main__':
    print((solve(eval(input()))))
# Original solution
import math

n = int(eval(input()))

mins = n
for i in range(1, int(math.sqrt(n))+1):
  if n % i == 0:
    mins = min(mins, i + (n // i) - 2)
print(mins)
             
        
        
  



# Optimized solution
import math
n = int(eval(input()))

ans = 1e+15
for i in range(1, int(math.sqrt(n))+1):
  if n % i == 0:
    ans = min(ans, i + n//i - 2)
    
print(ans)
# Original solution
def main():
    N = int(eval(input()))
    loop = int(N ** 0.5)

    ans = float("inf")
    for i in range(1, loop + 1):
        if N % i == 0:
            j = N // i
            tmp = i + j - 2

            if tmp < ans:
                ans = tmp
    print(ans)


if __name__ == "__main__":
    main()

# Optimized solution
def func(N):
    loop = int(N ** 0.5)

    ans = float("inf")
    for i in range(1, loop + 1):
        if N % i:
            continue
        j = N // i
        tmp = i + j - 2
        ans = min(ans, tmp)
    
    return ans


if __name__ == "__main__":
    N = int(eval(input()))
    
    print((func(N)))
# Original solution
N = int(eval(input()))
ans = []
for i in range(1,int(pow(N,0.5))+1):
    j = N//i
    if i*j == N:
        ans.append(i+j)

print((min(ans)-2))

# Optimized solution
N = int(eval(input()))
ans = []
for i in range(1,int(pow(N,0.5))+1):
    if N%i==0:
        ans.append(i+N//i)

print((min(ans)-2))
# Original solution
N = int(eval(input()))
ans = float("inf")


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)

    # divisors.sort()
    return divisors


for i in make_divisors(N):
    for j in make_divisors(N):
        if i * j == N:
            x = i - 1
            y = j - 1

            ans = min(ans, (i-1)+(j-1))
print(ans)


# Optimized solution
N = int(eval(input()))


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)

    # divisors.sort()
    return divisors


div = make_divisors(N)

if div[-1] ** 2 == N:
    print((div[-1]*2 - 2))

else:
    x = div[-2] - 1
    y = div[-1] - 1

    print((x + y))
# Original solution
N=int(eval(input()))
K=list()

for i in range(1,int(N**0.5)+1):
  if(int(N/i)==N/i):
    M=int(N/i)  #N<=M
    L=i
    K.append(M+L-2)
    
print((min(K)))

# Optimized solution
import math
def make_divisors(n):
    divisors = []
    for i in range(2, int(math.sqrt(n))+1):
        if n % i == 0:
            divisors.append(i)

    divisors.sort()
    return divisors

def main():
    N=int(eval(input()))
    di=make_divisors(N)
    if di==[]:
        print((N-1))
    else:
        M=N//di[-1]
        print((di[-1]-1+M-1))

if __name__=="__main__":
    main()
# Original solution
n = int(eval(input()))
a = n - 1
p = 1
for c in range(2, int((n ** 0.5) * 2)):
    if p % 2 == 1 and c > (n ** 0.5):
        break
    if n % c == 0:
        p = c
        w = int(n / c)
        if (w + c - 2) < a:
            a = (w + c -2)
        else:
            continue
    else:
        continue
print(a)


# Optimized solution
N = int(eval(input()))
ans = N - 1
p = 1
for i in range(2, int((N ** 0.5) + 1)):
    if p % 2 == 1 and i > (N ** 0.5):
        break
    if N % i == 0:
        p = i
        j = N // i
        m = i + j - 2
        if m < ans:
            ans = m
        else:
            continue
    else:
        continue
print(ans)
# Original solution
N = int(eval(input()))
ans = N - 1
p = 1
for i in range(2, int((N ** 0.5) + 1)):
    if p % 2 == 1 and i > (N ** 0.5):
        break
    if N % i == 0:
        p = i
        j = N // i
        m = i + j - 2
        if m < ans:
            ans = m
        else:
            continue
    else:
        continue
print(ans)


# Optimized solution
N = int(eval(input()))
ans = N - 1
for i in range(2, int((N ** 0.5) + 1)):
    if N % i == 0:
        j = N // i
        m = i + j - 2
        ans = min(ans, m)
print(ans)
# Original solution
n = int(eval(input()))
r = int(n**.5)
for i in range(r):
  if n % (r-i) == 0:
    print(( (r-i) + n//(r-i) - 2 ))
    break

# Optimized solution
n = int(eval(input()))
s = int(n**.5)
for i in range(s):
  if n % (s-i) == 0:
    print(((s-i) + n // (s-i) - 2))
    break
# Original solution
n = int(eval(input()))
def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct

a = factorize(n)
m = len(a)
ans = 0
if m==1:
    print((a[0]-1))
elif m==2:
    print((a[0]+a[1]-2))
elif m==3:
    z = a[0]*a[1]
    print((z+a[2]-2))
else:
    ans = 10**12
    for i in range(2**m):
        x = 1
        y = 1
        for j in range(m):
            if ((i>>j)&1):
                x *=a[j]
            else:
                y*=a[j]
        ans = min(ans, x+y-2)
    print(ans)

# Optimized solution
import math

INF = 1e12
n = int(eval(input()))
ans = INF
m = math.sqrt(n)
for i in range(1,math.ceil(m)+1):
    if n%i==0:
        j = n//i
        ans = min(ans, i+j-2)
    else:
        continue
print(ans)
# Original solution
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

N = I()

d = []
for i in range(1,int(N**.5)+1):
    if N % i == 0:
        d.append(i)
        if i != N//i:
            d.append(N//i)

d.sort()
a = len(d)

if a % 2 == 0:
    print((d[(a-1)//2] + d[(a+1)//2] - 2))
else:
    print((d[(a-1)//2]*2 - 2))

# Optimized solution
import sys

def I(): return int(sys.stdin.readline().rstrip())

N = I()

d = []  # Nの約数(Nが平方数のとき、N**.5を敢えて2回dに入れている)
for i in range(1,int(N**.5)+1):
    if N % i == 0:
        d.append(i)
        d.append(N//i)

# 目的地の(i,j)は、i*j==Nを満たす(i,j)の中でiとjが最も近いもの

d.sort()
a = len(d)

print((d[a//2] + d[a//2-1] - 2))
# Original solution
n=int(eval(input()))
a=-1
b=-1
for i in range(1,int(n**0.5)+1):
  #print(i,n/i)
  if n/i-int(n/i)==0:
    a=i
    b=int(n/i)
    
    
print((a+b-2))

# Optimized solution
n=int(eval(input()))
#n=a*bのa+b-2のmin
ans=float("inf")
for i in range(1,int(n**0.5)+1):
  if n%i==0:
    ans=min(ans,n//i+i-2)
print(ans)
# Original solution
n = int(eval(input()))
import math
for i in range(math.floor(n**0.5),0,-1):
  if n % i == 0:
    print((i + n//i -2))
    break

# Optimized solution
n = int(eval(input()))
for i in range(int(n**0.5)+1,0,-1):
  if n % i == 0:
    print((i + n//i -2))
    break
# Original solution
n=int(eval(input()))
for i in range(int(n**.5),0,-1):
  if n%i<1: print((i+n//i-2)); break

# Optimized solution
n=int(eval(input()))
print((min(i+n//i-2 for i in range(1,int(n**.5)+1) if n%i<1)))
# Original solution
n=int(eval(input()))

div = n
result = 10**12

for i in range(1,1000001):
  if n % i == 0:
    div = n // i
    result = min(result, i+div)

print((int(result-2)))



# Optimized solution
n=int(eval(input()))

result = 10**12
for i in range(1,int(n**0.5)+1):
  if n % i == 0:
    result = min(result, i + n//i)

print((int(result-2)))
# Original solution
import math
n=int(eval(input()))
lst=[]
down=math.floor(math.sqrt(n))
for i in range(1,down+1):
    if i**2>n:
        break
    if n%i==0:
        lst.append(i+n//i)
print((min(lst)-2))

# Optimized solution
import math
n=int(eval(input()))
lst=[]
down=math.floor(math.sqrt(n))
for i in range(1,down+1):
    #if i**2>n:
    #    break
    if n%i==0:
        lst.append(i+n//i)
print((min(lst)-2))
# Original solution
from math import *
n = int(eval(input()))

def ij(x):
    for i in range(x):
        i = x - i
        if n / i == n//i:
            return i, n//i

print((sum(ij(int(sqrt(n)))) - 2))


# Optimized solution
from math import *
n = int(eval(input()))

def ij(x):
    for i in range(x, 0, -1):
        if n/i == n//i:
            return i, n//i

print((sum(ij(int(sqrt(n)))) - 2))
# Original solution
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)
      divisors.append(n // i)
  return divisors

N = int(eval(input()))
l = make_divisors(N)
a = l[len(l) - 1]
b = l[len(l) - 2]
print((a + b - 2))

# Optimized solution
def make_divisors(n):
  divisors = []
  for i in range(int(n ** 0.5), 0, -1):
    if n % i == 0:
      divisors.append(i)
#      if i != n // i:
#        divisors.append(n // i)
      divisors.append(n // i)
      break
  return divisors

N = int(eval(input()))
l = make_divisors(N)
a = l[0]
b = l[1]
print((a + b - 2))
# Original solution
n = int(eval(input()))
def is_prime(num):
    import math
    if num == 2:
        return True
    elif num <  3 or num % 2 == 0:
        return False
    for i in range(3, int(math.sqrt(num)) + 1, 2):
        if num % i == 0:
            return False
    return True

if is_prime(n):
    print((n-1))
    exit()

ans = float('inf')
for i in range(n//2, 0, -1):
    if n%i == 0:
        ans = min(ans, (i-1)+(n//i-1))
print(ans)

# Optimized solution
n = int(eval(input()))
def is_prime(num):
    import math
    if num == 2:
        return True
    elif num <  3 or num % 2 == 0:
        return False
    for i in range(3, int(math.sqrt(num)) + 1, 2):
        if num % i == 0:
            return False
    return True

if is_prime(n):
    print((n-1))
    exit()

ans = float('inf')
for i in range(int(n**0.5), 0, -1):
    if n%i == 0:
        ans = min(ans, (i-1)+(n//i-1))
print(ans)
# Original solution
n = int(eval(input()))
l = []
for i in range(1,1000001):
    a = n / i
    if a.is_integer():
        l.append(i+n/i)
print((int(min(l)-2)))

# Optimized solution
n = int(eval(input()))
a = 10**20
for i in range(1,int(n**0.5)+1):
    if n%i==0:
        a = min(a,i+n//i)
print((a-2))
# Original solution
import math
n=int(eval(input()))
ans=n
i=1
while(i<=math.sqrt(n)):
    if n%i==0:
        d=i+n/i-2
        ans=min(ans,d)
    i+=1
print((int(ans)))

# Optimized solution
from math import floor
from math import sqrt
n=int(eval(input()))
nn=floor(sqrt(n))
rest=n%nn
while rest!=0:
    nn-=1
    rest=n%nn
nnn=n/nn
print((int(nn+nnn-2)))
# Original solution
n = int(eval(input()))
import math
m = int(math.sqrt(n))+1
anss = []
for x in range(1, m+1):
  y = n//x
  z = n%x
  if z == 0:
    anss.append(abs(x-1)+abs(y-1))
print((min(anss)))


# Optimized solution
n = int(eval(input()))
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)

    #divisors.sort(reverse=True)
    return divisors

l = make_divisors(n)
min_ = float('inf')
for i in range(len(l)):
    min_ = min(min_, l[i]-1+n//l[i]-1)
print(min_)
# Original solution
n = int(eval(input()))

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)

    #divisors.sort(reverse=True)
    return divisors

l = make_divisors(n)
ans = float('inf')
for a in l:
    b  = n//a
    ans = min(ans, a+b-2)
print(ans)

# Optimized solution
n =int(eval(input()))
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)

    #divisors.sort(reverse=True)
    return divisors

l = make_divisors(n)
ans = float('inf')
for i in l:
    ans = min(ans, i-1+n//i-1)
print(ans)
# Original solution
n =int(eval(input()))
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)

    #divisors.sort(reverse=True)
    return divisors

l = make_divisors(n)
ans = float('inf')
for i in l:
    ans = min(ans, i-1+n//i-1)
print(ans)


# Optimized solution
n = int(eval(input()))
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)

    divisors.sort()
    return divisors

d = make_divisors(n)
ans = 10**18
for a in d:
    ans = min(ans, n//a-1+a-1)
print(ans)
# Original solution
from math import sqrt
from sys import exit

N = int(eval(input()))

for i in range(int(sqrt(N)) +1, -1, -1):
  if N % i == 0:
    print(((i - 1) + (N // i - 1)))
    exit()

# Optimized solution
n = int(eval(input()))

t = int(n**0.5+1)
ans = 10**13
for i in range(1, t):
  if n%i == 0 and i+n//i-2 < ans:
    ans = i+n//i-2
print(ans)
# Original solution
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)

    # divisors.sort()
    return divisors


n = int(eval(input()))
divisors = make_divisors(n)

ans = 10**12
if len(divisors) % 2 == 0:
    for i in range(0, len(divisors), 2):
        ans = min(ans, divisors[i]+divisors[i+1])

else:
    for i in range(0, len(divisors)-1, 2):
        ans = min(ans, divisors[i]+divisors[i+1])
    ans = min(ans, divisors[-1]*2)
print((ans-2))


# Optimized solution
import math


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)

    divisors.sort()
    return divisors


n = int(eval(input()))
divisors = make_divisors(n)

ans = 10**13
for i in range(math.ceil(len(divisors)/2)):
    #print(divisors[i], divisors[len(divisors)-i-1])
    #print(divisors[i]+divisors[len(divisors)-i-1])
    ans = min(ans, divisors[i]+divisors[len(divisors)-i-1]-2)
print(ans)
# Original solution
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

N=int(eval(input()))
div=make_divisors(N)

from math import sqrt

tmpmin=10**16
for i in range(len(div)):
  if tmpmin>abs(sqrt(N)-div[i]):
    tmpmin=abs(sqrt(N)-div[i])
    minidx=i

a=div[minidx]
b=N//a

print((a-1+b-1))

# Optimized solution

from math import sqrt

N=int(eval(input()))
for i in range(int(sqrt(N)),0,-1):
  if N%i==0:
    a=i
    break
b=N//a
print((a-1+b-1))
# Original solution
n = int(eval(input()))
i = 1
ans = 10**13
while(i*i<=n):
    if n%i == 0:
        ans = min(ans,n//i+i-2)
    i+=1
print(ans)

# Optimized solution
n = int(eval(input()))

i = 1
ele = []
while i * i <= n:
    if n % i == 0:
        ele.append([i,n//i])
    i += 1

ans = 10**13
for i in range(len(ele)):
    ans = min(ans,ele[i][0]+ele[i][1]-2)
print(ans)