CodeEff/ECCO huggingface dataset:
# Original solution
from collections import deque
def fi(i, x):
    a, b = lines[i]
    return a*x+b

def find(x):
    if len(lines) == 1:
        return 0
    def f(i):
        # 0<=i<len(lines)-1
        return fi(i+1,x) > fi(i,x)
    mn, mx = 0, len(lines)-2
    idx = (mn+mx)//2
    if f(mn):
        return 0
    if not f(mx):
        return mx+1
    while mx-mn>1:
        if f(idx):
            mx, idx = idx, (mn + idx)//2
            continue
        mn, idx = idx, (mx + idx)//2
    return idx+1

def remove_lines():
    (x, y) = lines.popleft()
    a, b = x, y
    (e, f) = lines[0]
    while len(lines)-1:
        (c, d), (e, f) = (e, f), lines[1]
        if (c-e)*(b-d) < (d-f)*(a-c):
            break
        lines.popleft()
    lines.appendleft((x, y))

def insert(a, b):
    lines.appendleft((a, b))
    if len(lines) >= 3:
        remove_lines()

N, C = list(map(int, input().split()))
hs = list(map(int, input().split()))
r = 0
lines = deque([])
for i, h in enumerate(hs):
    if i!= 0:
        r = fi(find(h), h) + h**2+C
    insert(-2*h, r+h**2)
print(r)


# Optimized solution
def fi(i, x):
    a, b = lines[i]
    return a*x+b

def find(x):
    if len(lines) == 1:
        return 0
    def f(i):
        # 0<=i<len(lines)-1
        return fi(i+1,x) > fi(i,x)
    mn, mx = 0, len(lines)-2
    idx = (mn+mx)//2
    if f(mn):
        return 0
    if not f(mx):
        return mx+1
    while mx-mn>1:
        if f(idx):
            mx, idx = idx, (mn + idx)//2
            continue
        mn, idx = idx, (mx + idx)//2
    return idx+1

def remove_lines():
    (x, y) = lines.pop()
    a, b  = x, y
    (e, f) = lines[-1]
    while len(lines)-1:
        (c, d), (e, f) = (e, f), lines[-2]
        if (c-e)*(b-d) < (d-f)*(a-c):
            break
        lines.pop()
    lines.append((x, y))

def insert(a, b):
    lines.append((a, b))
    if len(lines) >= 3:
        remove_lines()

N, C = list(map(int, input().split()))
hs = list(map(int, input().split()))
r = 0
lines = []
for i, h in enumerate(hs):
    if i!= 0:
        r = fi(find(h), h) + h**2+C
    insert(-2*h, r+h**2)
print(r)
# Original solution
def fi(i, x):
    a, b = lines[i]
    return a*x+b

def find(x):
    if len(lines) == 1:
        return 0
    def f(i):
        # 0<=i<len(lines)-1
        return fi(i+1,x) > fi(i,x)
    mn, mx = 0, len(lines)-2
    idx = (mn+mx)//2
    if f(mn):
        return 0
    if not f(mx):
        return mx+1
    while mx-mn>1:
        if f(idx):
            mx, idx = idx, (mn + idx)//2
            continue
        mn, idx = idx, (mx + idx)//2
    return idx+1

def remove_lines():
    (x, y) = lines.pop()
    a, b  = x, y
    (e, f) = lines[-1]
    while len(lines)-1:
        (c, d), (e, f) = (e, f), lines[-2]
        if (c-e)*(b-d) < (d-f)*(a-c):
            break
        lines.pop()
    lines.append((x, y))

def insert(a, b):
    lines.append((a, b))
    if len(lines) >= 3:
        remove_lines()

N, C = list(map(int, input().split()))
hs = list(map(int, input().split()))
r = 0
lines = []
for i, h in enumerate(hs):
    if i!= 0:
        r = fi(find(h), h) + h**2+C
    insert(-2*h, r+h**2)
print(r)


# Optimized solution
def fi(i, x):
    a, b = lines[i]
    return a*x+b

def find(x):
    def f(i):
        return fi(i+1,x) > fi(i,x)
    mn, mx = -1, len(lines)-1
    idx = (mn+mx)//2
    while mx-mn>1:
        if f(idx):
            mx, idx = idx, (mn + idx)//2
            continue
        mn, idx = idx, (mx + idx)//2
    return fi(idx+1, x)

def insert(a, b):
    (e, f) = lines[-1]
    while len(lines)-1:
        (c, d), (e, f) = (e, f), lines[-2]
        if (c-e)*(b-d) < (d-f)*(a-c):
            break
        lines.pop()
    lines.append((a, b))

N, C = list(map(int, input().split()))
hs = list(map(int, input().split()))
lines = [(-2*hs[0], hs[0]**2)]
for h in hs[1:]:
    r = find(h) + h**2+C
    insert(-2*h, r+h**2)
print(r)
# Original solution
def fi(i, x):
    a, b = lines[i]
    return a*x+b

def find(x):
    def f(i):
        return fi(i+1,x) > fi(i,x)
    mn, mx = -1, len(lines)-1
    idx = (mn+mx)//2
    while mx-mn>1:
        if f(idx):
            mx, idx = idx, (mn + idx)//2
            continue
        mn, idx = idx, (mx + idx)//2
    return fi(idx+1, x)

def insert(a, b):
    (e, f) = lines[-1]
    while len(lines)-1:
        (c, d), (e, f) = (e, f), lines[-2]
        if (c-e)*(b-d) < (d-f)*(a-c):
            break
        lines.pop()
    lines.append((a, b))

N, C = list(map(int, input().split()))
hs = list(map(int, input().split()))
lines = [(-2*hs[0], hs[0]**2)]
for h in hs[1:]:
    r = find(h) + h**2+C
    insert(-2*h, r+h**2)
print(r)


# Optimized solution
N, C = list(map(int, input().split()))
hs = list(map(int, input().split()))
lines = [(-2*hs[0], hs[0]**2)]
I = 0
for h in hs[1:]:
    u, v = lines[I]
    while I+1<len(lines):
        uu, vv = lines[I+1]
        if u*h+v < uu*h+vv:
            break
        u, v = uu, vv
        I += 1
    r = u*h+v + h**2+C
    a, b = -2*h, r+h**2
    (e, f) = lines[-1]
    while len(lines)-1:
        (c, d), (e, f) = (e, f), lines[-2]
        if (c-e)*(b-d) < (d-f)*(a-c):
            break
        lines.pop()
    lines.append((a, b))
print(r)
# Original solution
eval(input())
l=list(map(int,input().split()))
print(('YES' if sum(i!=j for i,j in zip(l,sorted(l)))<3 else 'NO'))

# Optimized solution
eval(input());print(('YNEOS'[sum(i+1!=int(j) for i,j in enumerate(map(int,input().split())))>2::2]))
# Original solution
#a,b=map(int,input().split())
n=int(input())
p=list(map(int,input().split()))
import copy
P=copy.deepcopy(p)
P.sort()
cnt=0
for i,j in zip(p,P):
        if i!=j:
                cnt+=1
print("YES") if cnt<=2 else print("NO")


# Optimized solution
n=int(input())
p=list(map(int,input().split()))
#b=list(map(int,input().split()))
cnt=0
for i in range(n):
    if p[i]!=i+1:
        cnt+=1
print("YES") if cnt<=2 else print("NO")
# Original solution
import copy
n=int(eval(input()))
numl=list(map(int,input().split()))	
chk=sorted(numl)

flag=True
if chk==numl :
  flag=True
else :
  flag=False

for i in range(n) :
  #print(i)
  for j in range(n):
    #print(j)
    temp=copy.deepcopy(numl)
    temp[i]=numl[j]
    temp[j]=numl[i]
    #print(temp)
    if temp==chk :
      flag=True
      break

if flag==True:
  print("YES")
else :
  print("NO")
  







# Optimized solution
n=int(eval(input()))
#a,b=map(int,input().split())
pl=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
#sortedl=sorted(pl)
flag=False
if pl==sorted(pl):
    flag=True
else:
    for i in range(n):
        for j in range(n):
            templ=pl[:]
            templ[i]=pl[j]
            templ[j]=pl[i]
            if templ==(sorted(pl)):
                flag=True
                break
if flag:
    print("YES")
else:
    print("NO")
# Original solution
import copy

n = int(eval(input()))
p = list(map(int, input().split()))
p_new = copy.copy(p)
for i in range(n-1):
  if p[i] > p[i+1]:
    min_val = min(p[i+1:])
    for j in range(n):
      if p[j] == min_val:
        p_new[i] = min_val
        p_new[j] = p[i]
        break
    break

if p_new == sorted(p):
  print('YES')
else:
  print('NO')

# Optimized solution
n = int(eval(input()))
p = list(map(int, input().split()))

cnt = 0
for k,v in enumerate(p):
  if k+1 != v:
    cnt += 1

if cnt > 2:
  print('NO')
else:
  print('YES')
# Original solution
import copy


def actual(n, P):
    nums_asc = sorted(P)

    if nums_asc == P:
        return 'YES'

    N = len(P)
    for i in range(N):
        for j in range(1, N):
            swapped_nums = copy.deepcopy(P)

            swapped_nums[i] = P[j]
            swapped_nums[j] = P[i]

            if swapped_nums == nums_asc:
                return 'YES'

    return 'NO'

n = int(eval(input()))
P = list(map(int, input().split()))

print((actual(n, P)))

# Optimized solution
def actual(n, P):
    # 正しくない配置にある数字が2つ以下なら、1回以下のSwapで照準になる
    n_unmatched = [i == p for i, p in enumerate(P, start=1)].count(False)

    if n_unmatched <= 2:
        return 'YES'

    return 'NO'


n = int(eval(input()))
P = list(map(int, input().split()))

print((actual(n, P)))
# Original solution
n = int(eval(input()))
p = [int(i) for i in input().split()]
sp = sorted(p)
print(('YES' if sum(p[i] == sp[i] for i in range(n)) >= n - 2 else 'NO'))

# Optimized solution
n = int(eval(input()))
p = [int(i) for i in input().split()]
print(('YES' if sum(p[i] != i + 1 for i in range(n)) <= 2 else 'NO'))
# Original solution
n=int(eval(input()));lista_1=[];contador=0;index=0
lista=list(map(int,input().split()))
for i in range(1,n+1):
    lista_1.append(i)
for j in lista:
    aaa=lista_1[index]
    if(j!=aaa):
        contador=contador+1
    index=index+1
if(contador<=2):
    print('YES')
else:
    print('NO')

# Optimized solution
n=int(eval(input()))
arr=[int(i) for i in input().split()]
a=0
for i in range(n):
    if arr[i]!=i+1:
        a+=1
if a==2 or a==0:
    print("YES")
else:
    print("NO")
# Original solution
def main():
    N = int(eval(input()))
    P = list(map(int, input().split()))
    for i in range(N - 1):
        if P[i] > P[i + 1]:
            break
    for j in range(i + 1, N - 1):
        if P[j] > P[j + 1]:
            t = P[i]
            P[i] = P[j + 1]
            P[j + 1] = t
            break
    PP = P[::]
    P.sort()
    if P == PP:
        print('YES')
    else:
        print('NO')


main()


# Optimized solution
def main():
    _ = int(eval(input()))
    P = list(map(int, input().split()))
    c = 0
    for i, p in enumerate(P):
        if i + 1 != p:
            c += 1
    print(('YNEOS'[c > 2::2]))


main()
# Original solution
n = int(eval(input()))
p = tuple(map(int, input().split()))
a = list(p)

ans = []
for i in range(1,n+1):
  ans.append(i)

  

for i in range(n):
  for j in range(n):
    a[i] = p[j]
    a[j] = p[i]
    if a == ans:
      print('YES')
      exit()
    else:
      a = list(p)
    
      
      
      
    
print('NO')

# Optimized solution
n = int(eval(input()))
p = list(map(int, input().split()))
a = list(p)

ans = []
for i in range(1,n+1):
  ans.append(i)

  

for i in range(n):
  for j in range(n):
    a[i] = p[j]
    a[j] = p[i]
    if a == ans:
      print('YES')
      exit()
    else:
      a = list(p)
       
      
      
      
    
print('NO')
# Original solution
n = int(eval(input()))
p = [int(x) for x in input().split()]

cnt =0

for i in range(n):
  if p[i] ==(i+1):
    continue
  else:
    cnt +=1
if cnt <= 2:
  print('YES')
else:
  print('NO')

# Optimized solution
n =int(eval(input()))
p = [int(_) for _ in input().split()]
cnt =0
for i in range(len(p)):
  if  p[i] !=(i+1):
    cnt +=1
print(('YES' if cnt <=2 else 'NO'))
# Original solution
n = int(eval(input()))
s = list(map(int, input().split()))

if s == sorted(s):
  print('YES')
else:
  
  s1 = sorted(s)
  count = 0
  for i in range(n):
    if s1[i]!=s[i]: count+=1
      
  if count==2:
    print('YES')
  else:
    print('NO')



# Optimized solution
n = int(eval(input()))
p = list(map(int,input().split()))
p1 = sorted(p)
count = 0
for i in range(n):
  if p[i]!=p1[i]: count += 1
if count==0 or count==2: print('YES')
else: print('NO')
# Original solution
n = int(eval(input()))
p = list(map(int,input().split()))
ans = [i for i in range(1,n+1)]
cnt = 0
 
for i in range(n):
  if p[i] != ans[i]:
    cnt += 1
  if cnt > 2:
    print('NO')
    exit()
    
print('YES')

# Optimized solution
n = int(eval(input()))
p = list(map(int, input().split()))
error = 0
for i in range(n):
    if p[i] != i+1:
        error += 1
    if error > 2:
        print('NO')
        exit()
print('YES')
# Original solution
N=int(eval(input()))
p=[int(i) for i in input().split()]
flag=1
for k in range(N-1):
    if p[k]>p[k+1]:
        flag=0
        break
if flag==1:
    print("YES")
    exit()
for i in range(N):
    for j in range(N):
        if i>=j:
            continue
        q=[p[i] for i in range(N)]
        q[i],q[j]=q[j],q[i]
        flag=1
        for k in range(N-1):
            if q[k]>q[k+1]:
                flag=0
                break
        if flag==1:
            print("YES")
            exit()
print("NO")


# Optimized solution
N=int(eval(input()))
p=[int(i) for i in input().split()]
tmp=0
for i in range(N):
    if p[i]!=i+1:
        tmp+=1
if tmp<=2:
    print("YES")
else:
    print("NO")
# Original solution
N = int(eval(input()))
lis_p = list(map(int, input().split()))

lis_ans = sorted(lis_p)

count = 0
for i in range(N):
    if lis_p[i] != lis_ans[i]:
        count += 1

if count == 2 or count == 0:
    print("YES")
else:
    print("NO")

# Optimized solution
n=int(eval(input()))
p=list(map(int,input().split()))
g=sum((1 for i in range(n) if i+1 !=p[i]))
print(("YNEOS"[::2] if g==2 or g==0 else "YNEOS"[1::2]))
# Original solution
N=int(eval(input()))
p=list(map(int,input().split()))
diff=0
for i in range(N):
    if p[i]!=i+1:diff+=1
print(("YES" if diff==0 or diff==2 else "NO"))

# Optimized solution
N=int(eval(input()))
p=list(map(int,input().split()))
print(("YES" if sum(1 for i in range(N) if p[i]!=i+1)<=2 else "NO"))
# Original solution
import copy

n = int(eval(input()))
li = list(map(int,input().split()))

if all([li[i] < li[i+1] for i in range(n-1)]):
    print('YES')
    exit()
for i in range(n):
    for j in range(i+1,n):
        a = copy.copy(li)
        a[i],a[j] = a[j],a[i]
        if all([a[i] < a[i+1] for i in range(n-1)]):
            print('YES')
            exit()

print('NO')


# Optimized solution
n = int(eval(input()))
li = list(map(int,input().split()))

count = 0

for i in range(n):
    if li[i] != i+1:
        count += 1
if count <= 2:
    print('YES')
else:
    print('NO')
# Original solution
from heapq import heappush, heappop
from collections import deque
import itertools
from itertools import permutations
import sys
import bisect
sys.setrecursionlimit(10**6)
def MI():
    return list(map(int,input().split()))
def I():
    return int(eval(input()))
def LI():
    return [int(i) for i in input().split()]
YN=['Yes','No']
YN=['YES','NO']
YNeos='YNeos'
mo=10**9+7
imp='IMPOSSIBLE'


n=I()
a=LI()
ans=1
c=[i for i in a]
c.sort()
def rp(i,j):
    b=[i for i in a]
    b[i],b[j]=b[j],b[i]
    return b
for i in range(n):
    for j in range(i,n):
        d=rp(i,j)
        if d==c:
            ans=0

print((YN[ans]))



# Optimized solution
n=int(eval(input()))
a=[int(i) for i in input().split()]
c=0
for i in range(n):
  c+=(a[i]==i+1)*1
print((['YES','NO'][c<n-2]))
# Original solution
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    P = il()
    cnt = 0
    for n in range(N):
        if P[n] != n + 1:
            cnt += 1
        if P[P[n]-1] != n+1:
            print('NO')
            exit()
    print(('NO' if cnt > 3 else 'YES'))


if __name__ == '__main__':
    main()


# Optimized solution
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    P = il()

    cnt = 0
    for n in range(N):
        if P[n] != n + 1:
            cnt += 1
        if cnt > 2:
            print('NO')
            exit()
    else:
        print('YES')


if __name__ == '__main__':
    main()
# Original solution
import sys
N = int(eval(input()))
P = list(map(int,input().split()))

ans = sorted(P)

if P == ans:
  print("YES")
else:
  for i in range(N-1):
    for j in range(i+1,N):
      check = []
      check += P
      check[i],check[j] = check[j],check[i]
      if check == ans:
        print("YES")
        sys.exit()
  print("NO")

# Optimized solution
N = int(eval(input()))
P = list(map(int,input().split()))

cnt = 0
for i in range(N):
  if P[i] != i+1:
    cnt += 1
    
if cnt <= 2:
  print("YES")
else:
  print("NO")
# Original solution
_,p=open(0);print(('YNEOS'[sum(i!=int(p)for i,p in enumerate(p.split(),1))>2::2]))

# Optimized solution
_,p=open(0)
i=a=0
for p in p.split():i+=1;a+=int(p)!=i
print(('YNEOS'[a>2::2]))
# Original solution
n = int(eval(input()))
P = list(map(int, input().split()))
S = [i for i in range(1, n + 1)]
ans = "YES"
if P != S:
  ans = "NO"
  for i in range(n):
    for j in range(i + 1, n):
      P[i], P[j] = P[j], P[i]
      if P == S:
        ans = "YES"
        break
      P[i], P[j] = P[j], P[i]
print(ans)

# Optimized solution
n = int(eval(input()))
P = list(map(int, input().split()))
count = 0
for i in range(1, n + 1):
  if P[i - 1] != i:
    count += 1
print(("YES" if count <= 2 else "NO"))
# Original solution
n = int(eval(input()))
p = [int(x) for x in input().split()]
dif = 0
for i in range(n):
    if p[i] != i + 1:
        dif += 1
if dif == 0 or dif == 2:
    print('YES')
else:
    print('NO')

# Optimized solution
n = int(eval(input()))
p = [int(x) for x in input().split()]
dif = 0
for i in range(n):
    if p[i] != i + 1:  # 並び替えはせず、インデックスとの比較でOK
        dif += 1
if dif == 0 or dif == 2:
    print('YES')
else:
    print('NO')
# Original solution
N=int(eval(input()))
p=list(map(int,input().split()))
foundpair=False
foundi=False
sortedp=sorted(p)
pair=[]
if p==sortedp:
  print("YES")
  exit(0)
for i in range(N):
  if p[i]== sortedp[i]:
    continue
  else:
    if foundpair==False:
      if foundi:
        foundpair=True
        pair.append(i)
      else:
        foundi=True
        pair.append(i)
    else:
      print("NO")
      exit(0)
      
p[pair[0]],p[pair[1]]=p[pair[1]],p[pair[0]]
if p==sortedp:
  print("YES")
else:
  print("NO")
      

# Optimized solution
N=int(eval(input()))
p=list(map(int,input().split()))
count=0
pair=[]
for i in range(N):
  if p[i]== i+1:
    continue
  else:
    if count<2:
      count+=1
      pair.append(i)
    else:
      print("NO")
      exit(0)
      
print("YES")
# Original solution
n = int(eval(input()))
p = list(map(int, input().split()))
c = 0
for i in range(n):
    if p[i]!=i+1:
        c+=1
if c>2:
    print("NO")
else:
    print("YES")

# Optimized solution
x = int(eval(input()))
p = list(map(int, input().strip().split()))
k = sorted(p)
count = 0
for i in range(0,x):
    if p[i] == k[i]:
        count += 1

if (x - count) == 2 or (x - count) == 0:
    print('YES')
else:
    print('NO')
# Original solution
n = int(eval(input()))
p = list(map(int, input().split()))
s = sorted(p)
c = 0
for i in range(len(p)):
    if p[i] == s[i]:
        c += 1
if c >= len(p)-2:
    print('YES')
else:
    print('NO')

# Optimized solution
n = int(eval(input()))
p = list(map(int, input().split()))
l = [i+1 for i in range(n)]
c = 0
for i in range(n):
    if p[i] == l[i]:
        c += 1
print(('YES' if c >= n-2 else 'NO'))
# Original solution
n = int(eval(input()))
P = [int(x) for x in input().split()]
flag = True
for i in range(n):
    for j in range(n):
        if i == j:
            continue
        else:
            copy_P = P[:]
            copy_P[i], copy_P[j] = copy_P[j], copy_P[i]
            if copy_P == sorted(P):
                print("YES")
                flag = False
                break
    else:
        continue
    break
    
if sorted(P) == P:
    print("YES")
    flag = False

if flag:
    print("NO")

# Optimized solution
n = int(eval(input()))
p = [int(x) for x in input().split()]
p_copy = p[:]

p.sort()

count = 0
for i in range(n):
    if p[i] != p_copy[i]:
        count += 1

if count == 0 or count == 2:
    print("YES")
else:
    print("NO")
# Original solution
import copy

n = int(eval(input()))
p = list(map(int, input().split()))
q = copy.copy(p)
q.sort()
c = 0

for i in range(n):
    if p[i] != q[i]:
        c = c + 1

if c == 2 or c == 0:
    print("YES")
else:
    print("NO")

# Optimized solution
n = int(eval(input()))
p = list(map(int, input().split()))
c = 0

for i in range(n):
    if p[i] != i + 1:
        c = c + 1

if c == 2 or c == 0:
    print("YES")
else:
    print("NO")
# Original solution
A,B=list(map(int,input().split()))
if A%3==0 or B%3==0 or (A+B)%3==0:
    print('Possible')
else:
    print('Impossible')

# Optimized solution
a,b=list(map(int,input().split()))
if a%3==0 or b%3==0 or (a+b)%3==0:
  print("Possible")
else:
  print("Impossible")
# Original solution
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return eval(input())
def i(): return int(eval(input()))
def S(): return input().split()
def I(): return list(map(int,input().split()))
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

A,B = I()
if A%3 == 0 or B%3 == 0 or (A+B)%3 == 0:
    print('Possible')
else:
    print('Impossible')

# Optimized solution
A,B=list(map(int,input().split()))
if A%3*B%3*(A+B)%3==0:print('Possible')
else:print('Impossible')
# Original solution
A,B=list(map(int,input().split()))
if A%3*B%3*(A+B)%3==0:print('Possible')
else:print('Impossible')

# Optimized solution
A,B=list(map(int,input().split()));s='ossible'
if A%3*B%3*(A+B)%3==0:print(('P'+s))
else:print(('Imp'+s))
# Original solution
print(((eval(input().replace(*' *'))%3%2*'Imp'or'P')+'ossible'))

# Optimized solution
print(f"{eval(input().replace(*' *'))%3%2*'Imp'or'P'}ossible")
# Original solution
a = list(map(int,input().split()))
if a[0]%3==0 or a[1]%3==0 or (a[0]+a[1])%3==0:
  print("Possible")
else:
  print("Impossible")

# Optimized solution
A,B = list(map(int,input().split()))

if A%3==0 or B%3==0 or (A+B)%3==0:
  print("Possible")
else:
  print("Impossible")
# Original solution
A,B = list(map(int, input().split()))
if A%3 == 0 or B%3==0 or (A+B)%3 ==0:
    print('Possible')
else:
    print('Impossible')


# Optimized solution
A,B = list(map(int,input().split()))
print(('Possible' if A%3==0 or B%3==0 or (A+B)%3==0 else 'Impossible'))
# Original solution
from collections import Counter

mod = 10 ** 9 + 7
N = int(eval(input()))
X = list(map(int,input().split()))
L = [0] * N
for i in range(N):
    cnt = 0
    for j in range(i):
        if X[j] > cnt * 2:
            cnt += 1
    L[i] = i - cnt
d = Counter(L)
ans = 1
tmp = 0
for i in range(10 ** 5):
    tmp += d[i]
    if tmp == 0:
        break
    ans *= tmp
    ans %= mod
    tmp -= 1
print(ans)

# Optimized solution
from collections import Counter

mod = 10 ** 9 + 7
N = int(eval(input()))
X = list(map(int,input().split()))
L = [0] * N
for i in range(N-1):
    L[i+1] += L[i]
    if X[i] > L[i] * 2:
        L[i+1] += 1

for i in range(N):
    L[i] = i - L[i]

d = Counter(L)
ans = 1
tmp = 0
for i in range(10 ** 5):
    tmp += d[i]
    if tmp == 0:
        break
    ans *= tmp
    ans %= mod
    tmp -= 1
print(ans)