Problem:
Score : 400 points

Problem Statement

Akari has n kinds of flowers, one of each kind.

She is going to choose one or more of these flowers to make a bouquet.

However, she hates two numbers a and b, so the number of flowers in the bouquet cannot be a or b.

How many different bouquets are there that Akari can make?

Find the count modulo (10^9 + 7).

Here, two bouquets are considered different when there is a flower that is used in one of the bouquets but not in the other bouquet.

Constraints

All values in input are integers.

2 \leq n \leq 10^9

1 \leq a < b \leq \textrm{min}(n, 2 \times 10^5)

Input

Input is given from Standard Input in the following format:

n a b

Output

Print the number of bouquets that Akari can make, modulo (10^9 + 7). (If there are no such bouquets, print 0.)

Sample Input 1

4 1 3

Sample Output 1

7

In this case, Akari can choose 2 or 4 flowers to make the bouquet.

There are 6 ways to choose 2 out of the 4 flowers, and 1 way to choose 4, so there are a total of 7 different bouquets that Akari can make.

Sample Input 2

1000000000 141421 173205

Sample Output 2

34076506

Print the count modulo (10^9 + 7).

Solution in Haskell (GHC 7.10.3) (judge verdict: Accepted)

{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE BangPatterns #-}

-- Default Imports

import Control.Monad
import Control.Monad.ST
import Control.Monad.Trans.Class

import qualified Control.Monad.Reader as Reader
import Control.Monad.Reader (Reader, ReaderT, runReader, runReaderT)

import qualified Data.Array.MArray as MArray
import qualified Data.Array.ST as STArray
import Data.Array.ST (STArray, STUArray, runSTArray, runSTUArray)
import Data.Ix (Ix)

import qualified Data.Bits as Bits
import Data.Bits ((.&.), (.|.))

import qualified Data.ByteString.Char8 as BS
import Data.ByteString.Char8 (ByteString)

import qualified Data.Char as Char
import qualified Data.List as List
import qualified Data.Map.Strict as Map
import Data.Map.Strict (Map)
import qualified Data.Maybe as Maybe
import qualified Data.Set as Set
import Data.Set (Set)

import qualified Data.Vector as Vector
import qualified Data.Vector.Generic as GVector
import qualified Data.Vector.Mutable as MVector
import Data.Vector.Mutable (STVector)
import qualified Data.Vector.Unboxed as UVector

import Numeric

import Debug.Trace
-- ----------

-- Custom Import Here


-- ----------

-- Default Definitions

type Vector = Vector.Vector
-- type GVector = GVector.Vector
type UVector = UVector.Vector

readIntToList :: ByteString -> [Int]
readIntToList = List.unfoldr (fmap (second $ BS.dropWhile Char.isSpace) . BS.readInt)

readToList :: Read a => ByteString -> [a]
readToList = List.unfoldr $ fmap (mapTaken . mapRemain) . span' (not . Char.isSpace)
	where
		mapTaken  = first $ read . BS.unpack
		mapRemain = second $ BS.dropWhile Char.isSpace
		span' pred s
			| BS.null taken = Nothing
			| otherwise     = Just (taken, remain')
			where
				(taken, remain) = BS.span pred s
				remain' = BS.dropWhile Char.isSpace remain

readToListN :: Read a => Int -> ByteString -> [a]
readToListN n = take n . readToList

readIntToVector :: ByteString -> Vector Int
readIntToVector = Vector.unfoldr (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToUVector :: ByteString -> UVector.Vector Int
readIntToUVector = UVector.unfoldr (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToVectorN :: Int -> ByteString -> Vector.Vector Int
readIntToVectorN n = Vector.unfoldrN n (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace

readIntToUVectorN :: Int -> ByteString -> UVector.Vector Int
readIntToUVectorN n = UVector.unfoldrN n (fmap stripRemain . BS.readInt)
	where stripRemain = second $ BS.dropWhile Char.isSpace


first :: (a -> a') -> (a, b) -> (a', b)
first f (a, b) = (f a, b)

second :: (b -> b') -> (a, b) -> (a, b')
second f (a, b) = (a, f b)

average :: Fractional a => [a] -> a
average xs = sum xs / (fromIntegral . length) xs

modIntDivisor :: Int
modIntDivisor = floor 1e9 + 7

extGcd :: Integral a => Int -> Int -> (Int, Int)
extGcd a 0 = (1, 0)
extGcd a b = (x, y)
	where
		(x', y') = extGcd b (a `mod` b)
		x = y'
		y = x' - a `div` b * y'

newtype ModInt = ModInt { unModInt :: Int } deriving Eq

modInt :: Int -> ModInt
modInt x = ModInt $ (x `mod` modIntDivisor + modIntDivisor) `mod` modIntDivisor

modIntMap2 :: (Int -> Int -> Int) -> ModInt -> ModInt -> ModInt
modIntMap2 f a b = modInt $ f (unModInt a) (unModInt b)

instance Show ModInt where
	show = show . unModInt

instance Read ModInt where
	readsPrec n s = map (first ModInt) $ readsPrec n s

instance Num ModInt where
	(+) = modIntMap2 (+)
	(-) = modIntMap2 (-)
	(*) = modIntMap2 (*)
	abs = id
	signum _ = 1
	fromInteger = modInt . fromInteger

instance Enum ModInt where
	toEnum = modInt
	fromEnum = unModInt

minv :: ModInt -> ModInt
minv a = modInt y
	where (_, y) = extGcd modIntDivisor $ unModInt a

mdiv :: ModInt -> ModInt -> ModInt
mdiv x y = x * minv y

mperm :: ModInt -> ModInt -> ModInt
mperm _ 0 = 1
mperm n r = product [(n - r + 1)..n]

mcomb :: ModInt -> ModInt -> ModInt
mcomb n r = mperm n r `mdiv` product [1..r]

mpow' :: ModInt -> Int -> ModInt -> ModInt
mpow' _ 0 r = r
mpow' a b r = mpow' a' b' r'
	where
		(b', mb) = b `divMod` 2
		r' = if mb > 0 then r * a else r
		a' = a * a

mpow :: ModInt -> Int -> ModInt
mpow a b = mpow' a b 1
-- ----------

mcomb' :: Int -> Int -> ModInt
mcomb' n r = if n < r then 0 else mcomb (fromIntegral n) (fromIntegral r)

ans :: Int -> Int -> Int -> ModInt
ans n a b = mpow 2 n - mcomb' n a - mcomb' n b - 1

main :: IO ()
main = do
	[n, a, b] <- readToListN 3 <$> BS.getLine
	print $ ans n a b