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 Scala (2.11.7) (judge verdict: Accepted)

import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}

import scala.annotation.tailrec

object Main {
  val p = 1000000000 + 7

  @inline
  def submod(a: Long, b: Long): Long = {
    ((a - b) % p + p) % p
  }

  @inline
  def mulmod(a: Long, b: Long): Long = {
    a * b % p
  }

  @inline
  def invmod(a: Long): Long = {
    (extGCD(a, p)._1 + p) % p
  }

  def extGCD(a: Long, b: Long): (Long, Long, Long) = {
    if (b == 0) {
      (1L, 0L, a)
    } else {
      val (y, x, d) = extGCD(b, a % b)
      (x, y - a / b * x, d)
    }
  }

  def powerMod(a: Int, n: Int): Long = {
    @tailrec
    def power(cur: Long, a: Long, n: Int): Long = {
      if (n == 0) {
        cur
      } else {
        power(mulmod(cur, if (n % 2 == 0) 1 else a), mulmod(a, a), n / 2)
      }
    }

    power(1L, a, n)
  }

  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(new BufferedOutputStream(System.out))
    val Array(n, a, b) = in.readLine().split("\\s+").map(_.toInt)

    val power2n = powerMod(2, n)
    val a_fact = {
      var f = 1L
      for {
        i <- 2 to a
      } {
        f = mulmod(f, i)
      }
      f
    }
    val b_fact = {
      var f = a_fact
      for {
        i <- (a + 1) to b
      } {
        f = mulmod(f, i)
      }
      f
    }
    val na_fact = {
      var f = 1L
      for {
        i <- n to (n - a + 1) by -1
      } {
        f = mulmod(f, i)
      }
      f
    }
    val nb_fact = {
      var f = na_fact
      for {
        i <- (n - a) to (n - b + 1) by -1
      } {
        f = mulmod(f, i)
      }
      f
    }
    val b_fact_inv = invmod(b_fact)
    val a_fact_inv = invmod(a_fact)

    out.println(
      submod(
        submod(
          submod(power2n, 1),
          mulmod(
            na_fact,
            a_fact_inv
          )
        ),
        mulmod(
          nb_fact,
          b_fact_inv
        )
      )
    )

    out.flush()
  }
}