CodeEff/ECCO huggingface dataset:
# Original solution
n = int(eval(input()))
numlist = list(map(int,input().split()))
numcount = [0]*10**6

numset = set()
for num in numlist:
    numcount[num] += 1
    numset.add(num)
n = int(eval(input()))
anslist = []

for i in range(n):
    b,c = list(map(int,input().split()))
    numcount[c] += numcount[b]

    numcount[b] = 0
    numset.add(c)
    numset.discard(b)
    result = 0
    for num in list(numset):
        result += numcount[num]*num
    anslist.append(result)

for ans in anslist:
    print(ans)


# Optimized solution
n = int(eval(input()))
numlist = list(map(int,input().split()))
numcount = [0]*10**6

numset = set()
for num in numlist:
    numcount[num] += 1
    numset.add(num)
n = int(eval(input()))
anslist = []
result = 0
for num in list(numset):
    result += numcount[num]*num
    
for i in range(n):
    b,c = list(map(int,input().split()))
    numcount[c] += numcount[b]
    result += (c-b)*numcount[b]
    anslist.append(result)

    numcount[b] = 0
    numset.add(c)
    numset.discard(b)

for ans in anslist:
    print(ans)
# Original solution
import collections as c

n = int(eval(input()))

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

q = int(eval(input()))

s = sum(a)

cnt = c.Counter(a)

for i in range(100000):
    cnt[i] = a.count(i+1)

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

# Optimized solution
import collections as c

n = int(eval(input()))

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

q = int(eval(input()))

s = sum(a)

cnt = c.Counter(a)

for i in range(q):
    b,c = list(map(int,input().split()))
    s += (c-b)*cnt[b]
    cnt[c] += cnt[b]
    cnt[b] = 0
    print(s)
# Original solution
from collections import Counter

n = int(eval(input()))
a = list(map(int, input().split()))
q = int(eval(input()))
l = [list(map(int, input().split())) for _ in range(q)]
dic = Counter(a)

for i in range(q):
    (b, c) = l[i] 
    num = dic[b]
    dic[b] = 0
    if dic[c] == 0:
        dic[c] = num
    else:
        dic[c] += num
    ans = 0
    for i, j in list(dic.items()):
        ans += i*j
    print(ans)

# Optimized solution
from collections import Counter

n = int(eval(input()))
a = list(map(int, input().split()))
q = int(eval(input()))
l = [list(map(int, input().split())) for _ in range(q)]
dic = Counter(a)
S = sum(a)
for i in range(q):
    (b, c) = l[i] 
    num = dic[b]
    S -= b*num
    dic[b] = 0
    if dic[c] == 0:
        dic[c] = num
    else:
        dic[c] += num
    S += c*num
    print(S)
# Original solution
def main():
    from collections import Counter

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

    ans = [None] * Q
    A_Counter = Counter(A)
    for q in range(Q):
        B, C = list(map(int, input().split()))
        A_Counter[C] += A_Counter[B]
        A_Counter[B] = 0

        ans[q] = sum(A_Counter.elements())

    print(('\n'.join(map(str, ans))))


if __name__ == "__main__":
    main()


# Optimized solution
#!/usr/bin/env python3

def main():
    from collections import Counter

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

    ans = [None] * Q
    Asum = sum(A)
    A_Counter = Counter(A)
    for q in range(Q):
        B, C = list(map(int, input().split()))
        Asum = Asum + (C-B)*A_Counter[B]
        A_Counter[C] += A_Counter[B]
        A_Counter[B] = 0

        ans[q] = Asum

    print(('\n'.join(map(str, ans))))


if __name__ == "__main__":
    main()
# Original solution
ni = lambda: int(eval(input()))
nm = lambda: list(map(int, input().split()))
nl = lambda: list(map(int, input().split()))

n=ni()
a=nl()
nums = [0]*10**6
for i in range(n):
  nums[a[i]]+=1
q=ni()
for i in range(q):
  b,c=nm()
  nums[c]+=nums[b]
  nums[b]=0
  ans=0
  for j in range(len(nums)):
    ans+=nums[j]*j

  print(ans)


# Optimized solution
ni = lambda: int(eval(input()))
nm = lambda: list(map(int, input().split()))
nl = lambda: list(map(int, input().split()))

n=ni()
a=nl()
nums = [0]*10**6
for i in range(n):
  nums[a[i]]+=1
q=ni()
ans=0
for i in range(len(nums)):
  ans+=nums[i]*i

for i in range(q):
  b,c=nm()
  ans-=nums[b]*b
  ans+=nums[b]*c
  nums[c]+=nums[b]
  nums[b]=0
  print(ans)
# Original solution
N = int(eval(input()))
data = [int(i) for i in input().split()]
Q = int(eval(input()))

array = dict()
for i in data:
  if i in array:
    array[i] += 1
  else:
    array[i] = 1
    
for i in range(Q):
  quary = [int(i) for i in input().split()]
  if quary[0] not in array:
    pass
  elif quary[1] in array:
    array[quary[1]] += array[quary[0]]
    del array[quary[0]]
  else:
    array[quary[1]] = array[quary[0]]
    del array[quary[0]]
  
  total = 0
  for i, j in list(array.items()):
    total += i*j
  print(total)

# Optimized solution
N = int(eval(input()))
data = [int(i) for i in input().split()]
Q = int(eval(input()))

array = dict()
for i in data:
  if i in array:
    array[i] += 1
  else:
    array[i] = 1
    
total = 0
for i, j in list(array.items()):
  total += i*j
  
for i in range(Q):
  dt = 0
  quary = [int(i) for i in input().split()]
  if quary[0] not in array:
    pass
  elif quary[1] in array:
    dt = (quary[1]-quary[0])*array[quary[0]]
    array[quary[1]] += array[quary[0]]
    del array[quary[0]]
  else:
    dt = (quary[1]-quary[0])*array[quary[0]]
    array[quary[1]] = array[quary[0]]
    del array[quary[0]]
  
  total += dt
  print(total)
# Original solution
n = int(eval(input()))
a = [int(i) for i in input().split()]
sa  = sorted(a)

q = int(eval(input()))
b = []
for _ in range(q):
    b.append([int(i) for i in input().split()])


for i in range(q):
    idx = -1
    seta = set(sa)
    if b[i][0] in seta:
         idx = sa.index(b[i][0])
    # print(idx)

    if idx != -1:
        while (True):
            if idx < n and sa[idx] == b[i][0]:
                sa[idx] = b[i][1]
                idx += 1
            else:
                break
    # print(sa)
    print((sum(sa)))



# Optimized solution
n = int(eval(input()))
a = [int(i) for i in input().split()]


q = int(eval(input()))
b = []
for _ in range(q):
    b.append([int(i) for i in input().split()])

al = {}
suma = sum(a)

for i in a:
    if i not in al:
        al[i] = 1
    else:
        al[i] += 1

for i in range(q):
    if b[i][0] in al:
        suma += (b[i][1] - b[i][0]) * al[b[i][0]]
        
        if b[i][1] in al:
            
            al[b[i][1]] += al[b[i][0]]
            al[b[i][0]] = 0
        else:
            al[b[i][1]] = al[b[i][0]]
            al[b[i][0]] = 0
    print(suma)
# Original solution
import sys
from collections import Counter

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N = int(readline())
    A = list(map(int, readline().split()))
    Q, *BC = list(map(int, read().split()))

    total = sum(A)
    d = [0] * (10 ** 5 + 1)
    for a in A:
        d[a] += 1

    for b, c in zip(BC[::2], BC[1::2]):
        total += (c - b) * d[b]
        d[c] += d[b]
        d[b] = 0
        print(total)

    return


if __name__ == '__main__':
    main()


# Optimized solution
import sys
from collections import Counter

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N = int(readline())
    A = list(map(int, readline().split()))
    Q, *BC = list(map(int, read().split()))

    total = sum(A)
    d = [0] * (10 ** 5 + 1)
    for a in A:
        d[a] += 1

    for b, c in zip(*[iter(BC)] * 2):
        total += (c - b) * d[b]
        d[c] += d[b]
        d[b] = 0
        print(total)

    return


if __name__ == '__main__':
    main()
# Original solution
from collections import *
from operator import mul

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


A_dic = Counter(A)

for _ in range(q):
    b, c = list(map(int, input().split()))
    tmp = A_dic[b]
    A_dic[c] += tmp
    A_dic[b] = 0
    v, c = list(zip(*A_dic.most_common()))
    ans = list(map(mul, v, c))
    print((sum(ans)))

# Optimized solution
from collections import *
from operator import mul

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


A_dic = Counter(A)
A_sum = sum(A)

for _ in range(q):
    b, c = list(map(int, input().split()))
    tmp = A_dic[b]
    A_dic[c] += tmp
    A_dic[b] = 0
    A_sum += tmp*(c - b)
    print(A_sum)
# Original solution
n = int(eval(input()))
dic = {}
for i in input().split():
    if i not in dic:
        dic[i] = 0
    dic[i] += 1
q = int(eval(input()))
for j in range(q):
    b,c = (str(x) for x in input().split())
    if b not in dic:
        pass
    else:
        if c not in dic:
            dic[c] = dic[b]
            dic[b] = 0
        else:
            dic[c] += dic[b]
            dic[b] = 0
    ans = 0
    for k in dic:
        ans += int(k)*dic[k]
    print(ans)


# Optimized solution
n = int(eval(input()))
dic = {}
list = [int(i) for i in input().split()]
for i in list:
    if i not in dic:
        dic[i] = 0
    dic[i] += 1
q = int(eval(input()))
ans = sum(list)
for j in range(q):
    b,c = (int(x) for x in input().split())
    if b not in dic:
        print(ans)
        continue
    else:
        if c not in dic:
            dic[c] = dic[b]
        else:
            dic[c] += dic[b]
    ans = ans + (c-b)*dic[b]
    dic[b] = 0
    print(ans)
# Original solution
from collections import Counter

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

counter = Counter(a)
sum_res = sum(a)  # はじめの合計、名前がsumだとsum関数とかぶってよくないので

# q回操作します。ループ変数は使わないので_とします（Pythonの慣習）
for _ in range(q):
    before, after = list(map(int, input().split()))

    # 合計を変更します
    sum_res -= before * counter[before]
    sum_res += after * counter[before]

    # 個数を変更します
    counter[after] += counter[before]
    counter[before] = 0

    print(sum_res)

# Optimized solution
from collections import Counter

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

cou = Counter(a)
s = sum(a)

for b, c in bc:
    s = s + cou[b]*(c-b)
    cou[c] += cou[b]
    cou[b] = 0
    print(s)
# Original solution
n = int(eval(input()))
a = input().split()
q = int(eval(input()))

for i in range(q):
    stdins = input().split()
    for j in range(n):
        a[j] = a[j].replace(stdins[0], stdins[1])
    ans = sum([int(an) for an in a])
    print(ans)


# Optimized solution
n = int(eval(input()))
a = [int(an) for an in input().split()]
q = int(eval(input()))

for i in range(q):
    stdins = input().split()
    for j in range(n):
        if a[j] == int(stdins[0]):
            a[j] = int(stdins[1])
    ans = sum([int(an) for an in a])
    print(ans)
# Original solution
from sys import stdin
from sys import setrecursionlimit
from collections import Counter
setrecursionlimit(10 ** 7)

n = int(eval(input()))
a = list(map(int,stdin.readline().rstrip().split()))

q = int(eval(input()))
cc = Counter(a)

for _ in range(q):
    b,c = list(map(int,input().split()))
    cc[c] += cc[b]
    cc[b] -= cc[b]
    su = 0
    for i,j in list(cc.items()):
        su += i*j
    print(su)

# Optimized solution
from sys import stdin
from sys import setrecursionlimit
from collections import Counter
setrecursionlimit(10 ** 7)

n = int(eval(input()))
a = list(map(int,stdin.readline().rstrip().split()))
su = sum(a)

q = int(eval(input()))
cc = Counter(a)

for _ in range(q):
    b,c = list(map(int,input().split()))
    cc[c] += cc[b]
    su += c*cc[b]-b*cc[b]
    cc[b] -= cc[b]
    print(su)
# Original solution
from sys import stdin

N = int(stdin.readline())
A = list(map(int,stdin.readline().split()))
A.sort()
Q = int(stdin.readline())
D = dict()
S = set(A)
sum=0
count=0

for y in range(0,N):
    sum+=A[y]
    if y>0 and A[y]!=A[y-1]:
        D[A[y-1]]=count
        count=1
    elif y==0:
        count=1
    else:
        count+=1
    if y==N-1:
        D[A[y]]=count

for u in range(0,Q):
    U= list(map(int,stdin.readline().split()))
    SS=S.copy()
    SS.add(U[0])
    if len(SS)==len(S):

        SS.add(U[1])
        if len(SS)==len(S):
            sum+=(D[U[0]])*(U[1]-U[0])

            D[U[1]]+=D[U[0]]
            D[U[0]]=0
        else:
            sum += (D[U[0]]) * (U[1] - U[0])
            D[U[1]]=D[U[0]]
            D[U[0]]=0
        S=SS

    print(sum)

# Optimized solution
from sys import stdin

N = int(stdin.readline())
A = list(map(int,stdin.readline().split()))
A.sort()
Q = int(stdin.readline())
D = dict()
S = set(A)
sum=0
count=0

for y in range(0,N):
    sum+=A[y]
    if y>0 and A[y]!=A[y-1]:
        D[A[y-1]]=count
        count=1
    elif y==0:
        count=1
    else:
        count+=1
    if y==N-1:
        D[A[y]]=count

for u in range(0,Q):
    U= list(map(int,stdin.readline().split()))
    if U[0] in D:
        sum+=(D[U[0]])*(U[1]-U[0])
        if U[1] in D:
            D[U[1]]+=D[U[0]]
        else:
            D[U[1]]=D[U[0]]
        D[U[0]]=0


    print(sum)
# Original solution
N=int(eval(input()))
listA=list(map(int, input().split()))
Q=int(eval(input()))

listB=[] #appendのために宣言が必要
while True:
    try:
        listB.append(list(map(int,input().split())))

    except:
        break;
        
sum=sum(listA)
numlist=[0]*(10**5+1)
for i in range(10**5+1):
  numlist[i]=listA.count(i)
  
for i in range(Q):
  B=listB[i][0]
  C=listB[i][1]
  if numlist[B]!=0:
    sum=sum+(C-B)*numlist[B]
    # print(C)
    numlist[C]+=numlist[B]
    numlist[B]=0
    # print(numlist)
  print(sum)


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

listB=[] #appendのために宣言が必要
while True:
    try:
        listB.append(list(map(int,input().split())))

    except:
        break;
        
sum=sum(listA)
numlist=[0]*(10**5+1)
for i in listA:
  numlist[i]+=1
  
for i in range(Q):
  B=listB[i][0]
  C=listB[i][1]
  if numlist[B]!=0:
    sum=sum+(C-B)*numlist[B]
    # print(C)
    numlist[C]+=numlist[B]
    numlist[B]=0
    # print(numlist)
  print(sum)
# Original solution
#import math
#import numpy as np
#import torch
#import torch.nn as nn
#import matplotlib.pyplot as plt
#from decimal import Decimal
#import itertools
import collections

N=int(eval(input()))
#N,K = map(int,input().split())
#B,W = map(int,input().split())
#T=int(input())
A = list(map(int,input().split()))
#S=str(input())
#A=[p for p in range(2*10**5)]
Q=int(eval(input()))
l=[]
for i in range(Q):
    #print(A)
    B,C = list(map(int,input().split()))

    A=[C if x==B else x for x in A]
    
    print((sum(A)))


# Optimized solution
#import math
#import numpy as np
#import torch
#import torch.nn as nn
#import matplotlib.pyplot as plt
#from decimal import Decimal
#import itertools
import collections

N=int(eval(input()))
#N,K = map(int,input().split())
#B,W = map(int,input().split())
#T=int(input())
A = list(map(int,input().split()))
#S=str(input())
#A=[p for p in range(2*10**5)]
Q=int(eval(input()))
c=collections.Counter(A)
s=sum(A)
for i in range(Q):
    #print(A)
    B,C = list(map(int,input().split()))
    if c[B]:
        s += (C-B)*c[B]
        c[C] += c[B]
        c[B] = 0

    print(s)
# Original solution
n = int(eval(input()))
*a, = list(map(int, input().split()))
q = int(eval(input()))
d = [0]*(10**5+1)
for i in a:
    d[i] += 1
for _ in [0]*q:
    b, c = list(map(int, input().split()))
    d[c] += d[b]
    d[b] = 0
    print((sum(i*j for i, j in enumerate(d))))

# Optimized solution
n = int(eval(input()))
*a, = list(map(int, input().split()))
q = int(eval(input()))
d = {}
for i in a:
    if i in d:
        d[i] += 1
    else:
        d[i] = 1
ans = sum(a)
for _ in [0]*q:
    b, c = list(map(int, input().split()))
    if b in d:
        if c in d:
            d[c] += d[b]
        else:
            d[c] = d[b]
        ans += (c-b)*d[b]
        d[b] = 0
    print(ans)
# Original solution
n = int(eval(input()))
a = list(map(int, input().split()))
q = int(eval(input()))
b = [0] * q
c = [0] * q
for i in range(q):
    b[i], c[i] = list(map(int, input().split()))

num_dict = dict()
for i in a:
    if i in list(num_dict.keys()):
        num_dict[i] += 1
    else:
        num_dict[i] = 1

for i in range(q):
    ans = 0
    if b[i] in num_dict:
        if c[i] in num_dict:
            num_dict[c[i]] += num_dict.pop(b[i])
        else:
            num_dict[c[i]] = num_dict.pop(b[i])
    for k, v in list(num_dict.items()):
        ans += k*v
    print(ans)

# Optimized solution
n = int(eval(input()))
a = list(map(int, input().split()))
q = int(eval(input()))
b = [0] * q
c = [0] * q
for i in range(q):
    b[i], c[i] = list(map(int, input().split()))

num_dict = dict()
for i in a:
    if i in list(num_dict.keys()):
        num_dict[i] += 1
    else:
        num_dict[i] = 1

ans = 0       
for k, v in list(num_dict.items()):
  ans += k*v
 
for i in range(q):
    if b[i] in num_dict:
        if c[i] in num_dict:
            ans += (c[i] - b[i]) * num_dict[b[i]]
            num_dict[c[i]] += num_dict.pop(b[i])
        else:
            ans += (c[i] - b[i]) * num_dict[b[i]]
            num_dict[c[i]] = num_dict.pop(b[i])
    #print(num_dict)
    print(ans)
# Original solution
from collections import Counter
n = int(eval(input()))
nums = list(map(int, input().split()))
q = int(eval(input()))
vals = [tuple(map(int, input().split())) for _ in range(q)]

c = Counter(nums)

for b, k in vals:
    o = c[b]
    del c[b]
    c[k] += o
    total = sum([x*y for x, y in list(c.items())])
    print(total)

# Optimized solution
from collections import Counter
n = int(eval(input()))
nums = list(map(int, input().split()))
q = int(eval(input()))
vals = [tuple(map(int, input().split())) for _ in range(q)]

c = Counter(nums)
total = sum([x*y for x, y in list(c.items())])
for b, k in vals:
    o = c[b]
    del c[b]
    c[k] += o
    total += k * o - b * o
    print(total)
# Original solution
# from math import sqrt
# from heapq import heappush, heappop
# from collections import deque
from operator import mul
from functools import reduce
# a, b = [int(v) for v in input().split()]


def main():

    def modcmb(n, r, mod):
        if r < 0 or r > n:
            return 0
        r = min(r, n - r)
        over = 1
        under = 1
        for i in range(r):
            over = over * (n - i) % mod
            under = under * (i + 1) % mod

#        over = reduce(lambda v1, v2: (v1 * v2) % mod, range(n, n-r, -1))
#        under = reduce(lambda v1, v2: (v1 * v2) % mod, range(1, r+1))
        return (over * pow(under, mod - 2, mod)) % mod

    mod = 1000000007
    n, a, b = list(map(int, input().split()))

    count = pow(2, n, mod) - 1
    count -= modcmb(n, a, mod)
    count -= modcmb(n, b, mod)

    while count < 0:
        count += mod
    print((count % mod))


main()


# Optimized solution
# from math import sqrt
# from heapq import heappush, heappop
# from collections import deque
from operator import mul
from functools import reduce
# a, b = [int(v) for v in input().split()]


def main():

    def modcmb(n, r, mod):
        if r < 0 or r > n:
            return 0
        r = min(r, n - r)
        over = 1
        under = 1
        for i in range(n, n-r, -1):
            over = over * i % mod
        for i in range(1, r+1):
            under = under * i % mod

#        over = reduce(lambda v1, v2: (v1 * v2) % mod, range(n, n-r, -1))
#        under = reduce(lambda v1, v2: (v1 * v2) % mod, range(1, r+1))
        return (over * pow(under, mod - 2, mod)) % mod

    mod = 1000000007
    n, a, b = list(map(int, input().split()))

    count = pow(2, n, mod) - 1
    count -= modcmb(n, a, mod)
    count -= modcmb(n, b, mod)

    while count < 0:
        count += mod
    print((count % mod))


main()
# Original solution
# from math import sqrt
# from heapq import heappush, heappop
# from collections import deque
from operator import mul
from functools import reduce
# a, b = [int(v) for v in input().split()]


def main():

    def modcmb(n, r, mod):
        if r < 0 or r > n:
            return 0
        r = min(r, n - r)
        if r == 0:
            return 1
        over = 1
        under = 1
#        for i in range(n, n-r, -1):
#            over = over * i % mod
#        for i in range(1, r+1):
#            under = under * i % mod

        over = reduce(lambda v1, v2: (v1 * v2) % mod, list(range(n, n-r, -1)))
        under = reduce(lambda v1, v2: (v1 * v2) % mod, list(range(1, r+1)))
        return (over * pow(under, mod - 2, mod)) % mod

    mod = 1000000007
    n, a, b = list(map(int, input().split()))

    count = pow(2, n, mod) - 1
    count -= modcmb(n, a, mod)
    count -= modcmb(n, b, mod)

    while count < 0:
        count += mod
    print((count % mod))


main()


# Optimized solution
# from math import sqrt
# from heapq import heappush, heappop
# from collections import deque
from operator import mul
from functools import reduce
# a, b = [int(v) for v in input().split()]


def main():

    mod = 1000000007
    n, a, b = list(map(int, input().split()))

    def combi(n, r):
        if r < 0 or r > n:
            return 0
        r = min(n - r, r)

        over = 1
        under = 1

        for i in range(n - r + 1, n + 1):
            over = over * i % mod

        for i in range(1, r + 1):
            under = under * i % mod

        return over * modpow(under, mod-2) % mod

    def modpow(n, r):
        if r == 0:
            return 1

        v = modpow(n, r // 2)
        v = v * v % mod
        if r % 2 != 0:
            v = v * n % mod
        return v

    ans = modpow(2, n) - 1
    ans -= combi(n, a)
    ans -= combi(n, b)

    while ans < 0:
        ans += mod

    print(ans)


main()
# Original solution
n, a, b = list(map(int, input().split()))
mod = 10**9 + 7


def neko(n, k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    k = min(n - k, k)
    ans = 1
    inv = [1] * (k + 1)
    if k >= 1:
        ans *= (n - k + 1) % mod
    for i in range(2, k + 1):
        inv[i] = mod - inv[mod % i] * (mod // i) % mod
        ans = ans * (n - k + i) * inv[i] % mod
    return ans


print(((pow(2, n, mod) - 1 - neko(n, a) - neko(n, b)) % mod))


# Optimized solution
n, a, b = list(map(int, input().split()))
mod = 10**9 + 7


def neko(n, r):
    p, q = 1, 1
    for i in range(r):
        p = p * (n - i) % mod
        q = q * (i + 1) % mod
    return p * pow(q, mod - 2, mod) % mod


print(((pow(2, n, mod) - 1 - neko(n, a) - neko(n, b)) % mod))
# Original solution
M = 10**9 + 7
n, a, b = list(map(int, input().split()))
r = pow(2, n, M) - 1
f = c = 1
for i in range(b):
  f = f * (i + 1) % M
  c = c * (n - i) % M
  if i + 1 in (a, b):
    r -= c * pow(f, M - 2, M)
print((r % M))


# Optimized solution
M = 10**9 + 7
n, a, b = list(map(int, input().split()))
r = pow(2, n, M) - 1
f = c = 1
for i in range(b):
  f = f * (i + 1) % M
  c = c * (n - i) % M
  if a != i + 1 != b:
    continue
  r -= c * pow(f, M - 2, M)
print((r % M))
# Original solution
M = 10**9 + 7
n, a, b = list(map(int, input().split()))
r = pow(2, n, M) - 1
f = c = 1
for i in range(b):
  f = f * (i + 1) % M
  c = c * (n - i) % M
  if i + 1 in (a, b):
    r -= c * pow(f, M - 2, M)
print((r % M))


# Optimized solution
M = 10**9 + 7
n, a, b = list(map(int, input().split()))
r = pow(2, n, M) - 1
f = c = 1
for i in range(b):
  f = f * (i + 1) % M
  c = c * (n - i) % M
  if i + 1 == a:
    a = b
    r -= c * pow(f, M - 2, M)
print((r % M))
# Original solution
from math import factorial
 
M = 10**9 + 7
n, a, b = list(map(int, input().split()))
r = pow(2, n, M) - 1
c = 1
for i in range(b):
  c = c * (n - i) % M
  if i + 1 == a:
    r -= c * pow(factorial(a) % M, M - 2, M)
    a = b
print((r % M))


# Optimized solution
M = 10**9 + 7
n, a, b = list(map(int, input().split()))
r = pow(2, n, M) - 1
f = c = 1
for i in range(b):
  f = f * (i + 1) % M
  c = c * (n - i) % M
  if i + 1 == a:
    a = b
    r -= c * pow(f, M - 2, M)
print((r % M))