Devu wants to decorate his garden with flowers. He has purchased n boxes, where the i-th box contains fi flowers. All flowers in a single box are of the same color (hence they are indistinguishable). Also, no two boxes have flowers of the same color.Now Devu wants to select exactly s flowers from the boxes to decorate his garden. Devu would like to know, in how many different ways can he select the flowers from each box? Since this number may be very large, he asks you to find the number modulo (109 + 7). Devu considers two ways different if there is at least one box from which different number of flowers are selected in these two ways.

The first line of input contains two space-separated integers n and s (1 ≤ n ≤ 20, 0 ≤ s ≤ 1014). The second line contains n space-separated integers f1, f2, ... fn (0 ≤ fi ≤ 1012).

Output a single integer — the number of ways in which Devu can select the flowers modulo (109 + 7).

NoteSample 1. There are two ways of selecting 3 flowers: {1, 2} and {0, 3}.Sample 2. There is only one way of selecting 4 flowers: {2, 2}.Sample 3. There are three ways of selecting 5 flowers: {1, 2, 2}, {0, 3, 2}, and {1, 3, 1}.

{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE BangPatterns #-}
import Data.Maybe
import Data.Char
import Data.List
import Data.Int
import Data.Bits
import Data.IORef
import Data.Array.IO
import Control.Monad
import Control.Applicative
import qualified Data.ByteString.Char8 as BS
import qualified Data.Map              as Map
import qualified Data.Set              as Set
import Text.Printf

modulo = 1000000007

power x n
  | n == 0 = 1
  | n `mod` 2 == 0 = xx * xx `mod` modulo
  | otherwise      = x * (power x (n - 1)) `mod` modulo
  where xx = power x (n `div` 2)

inverse :: Int64 -> Int64
inverse x = power x (modulo - 2)

coef :: Int64 -> Int64 -> (IOUArray Int64 Int64) -> IO Int64
coef n r invfact
  | n - r < r = do coef n (n - r) invfact
  | otherwise = do let nn = n `mod` modulo
                   readArray invfact r >>= \invp -> return (invp * (foldl' (\x y -> prod x y) 1 [nn, nn - 1.. nn - r + 1]) `mod` modulo)
                   where prod x y = x * y `mod` modulo

lim = 22

main = do
  [na, s] <- map (fromIntegral . fst) . mapMaybe BS.readInteger . BS.words <$> BS.getLine
  as      <- map ((+) 1) . map (fromIntegral . fst) . mapMaybe BS.readInteger . BS.words <$> BS.getLine
  invfact <- newArray (0, lim) 1 :: IO (IOUArray Int64 Int64)
  forM_ [1 .. lim] $ \x -> do
    let inv = inverse x
    prev <- readArray invfact (x - 1)
    writeArray invfact x (prev * inv `mod` modulo)
  res <- newIORef 0 :: IO (IORef Int64)
  let n = fromIntegral na :: Int
      nEnd = (1::Int) `shiftL` n
  forM_ [0.. nEnd - 1] $ \mask -> do
    let e = sum . map snd . filter (\(is, a) -> is) $ zip (map (testBit mask) [0.. n - 1]) as
    if e > s
      then return ()
      else do let sgn = if popCount mask `mod` 2 == 0 then 1 else (-1)
                  k = s - e
              c   <- coef  (fromIntegral n + k - 1) k invfact
              let tmp = (modulo + (sgn * c) `mod` modulo) `mod` modulo
              prev <- readIORef res
              let c = ((prev + tmp) `mod` modulo)
              writeIORef res $! c
  readIORef res >>= putStrLn . show

{-# OPTIONS_GHC -O2 #-}
import Data.Maybe
import Data.Char
import Data.List
import Data.Int
import Data.Bits
import Data.IORef
import Data.Array.IO
import Control.Monad
import Control.Applicative
import qualified Data.ByteString.Char8 as BS
import qualified Data.Map              as Map
import qualified Data.Set              as Set
import Text.Printf

modulo = 1000000007

power x n
  | n == 0 = 1
  | n `mod` 2 == 0 = xx * xx `mod` modulo
  | otherwise      = x * (power x (n - 1)) `mod` modulo
  where xx = power x (n `div` 2)

inverse :: Int64 -> Int64
inverse x = power x (modulo - 2)

coef :: Int64 -> Int64 -> (IOUArray Int64 Int64) -> IO Int64
coef n r invfact
  | n - r < r = do coef n (n - r) invfact
  | otherwise = do invp <- readArray invfact r
                   let nn = n `mod` modulo
                       factp = foldl' (\x y -> x * y `mod` modulo) 1 [nn, nn - 1.. nn - r + 1]
                   return (invp * factp `mod` modulo)

lim = 44

main = do
  [na, s] <- map (fromIntegral . fst) . mapMaybe BS.readInteger . BS.words <$> BS.getLine
  as      <- map (fromIntegral . fst) . mapMaybe BS.readInteger . BS.words <$> BS.getLine
  invfact <- newArray (0, 44) 1 :: IO (IOUArray Int64 Int64)
  forM_ [1 .. lim] $ \x -> do
    let inv = inverse x
    prev <- readArray invfact (x - 1)
    writeArray invfact x (prev * inv `mod` modulo)
  res <- newIORef 0 :: IO (IORef Int64)
  let n = fromIntegral na :: Int
      nEnd = (1::Int) `shiftL` n
      sets = [1.. nEnd - 1]
      sgns = map (\x -> if popCount x `mod` 2 == 0 then 1 else (-1)) sets
      args = [(s, as) | s <- sets]
  forM_ [0.. nEnd - 1] $ \mask -> do
--    putStrLn (show mask)
    let e = sum . map f $ zip (map (testBit mask) [0.. n - 1]) as
        f (True, a)  = a + 1
        f (False, a) = 0
    if e > s
      then return () -- solve1 (mask + 1) nEnd as n s
      else do let sgn = if popCount mask `mod` 2 == 0 then 1 else (-1)
                  k = s - e
              c   <- coef  (fromIntegral n + k - 1) k invfact
              let tmp = (modulo + (sgn * c) `mod` modulo) `mod` modulo
              prev <- readIORef res
              let c = ((prev + tmp) `mod` modulo)
              writeIORef res $! c

  fin <- readIORef res
  putStrLn . show $ fin

{-# OPTIONS_GHC -O2 #-}
import Data.Maybe
import Data.Char
import Data.List
import Data.Int
import Data.Bits
import Data.IORef
import Data.Array.IO
import Control.Monad
import Control.Applicative
import qualified Data.ByteString.Char8 as BS
import qualified Data.Map              as Map
import qualified Data.Set              as Set
import Text.Printf

modulo = 1000000000 + 7

power x n
  | n == 0 = 1
  | n `mod` 2 == 0 = xx * xx `mod` modulo
  | otherwise      = x * (power x (n - 1)) `mod` modulo
  where xx = power x (n `div` 2)

inverse x = power x (modulo - 2)

coef n r
  | n - r < r = coef n (n - r)
  | otherwise = let den = map inverse [1.. r]
                    nom = [n, n - 1.. (n - r + 1)]
                    calc []     = 1
                    calc (a:as) = a * (calc as) `mod` modulo
                in (calc nom) * (calc den) `mod` modulo

solve1 mask nEnd as n s
  | mask == nEnd = return 0
  | otherwise =  do let e = sum . map f $ zip (map (testBit mask) [0.. n - 1]) as
                        f (True, a)  = a + 1
                        f (False, a) = 0
                    if e > s
                      then solve1 (mask + 1) nEnd as n s
                      else do let sgn = if popCount mask `mod` 2 == 0 then 1 else (-1)
                                  k = s - e
                                  c = coef (n + k - 1) k
                              nxt <- solve1 (mask + 1) nEnd as n s
                              return ((nxt + sgn * c) `mod` modulo)

main = do
  [na, s] <- map (fromIntegral . fst) . mapMaybe BS.readInteger . BS.words <$> BS.getLine
  as      <- map (fromIntegral . fst) . mapMaybe BS.readInteger . BS.words <$> BS.getLine
  let n    = fromIntegral na :: Int
      nEnd = (1::Int) `shiftL` n
  solve1 0 nEnd as n s >>= putStrLn . show

{-# OPTIONS_GHC -O2 #-}
import Data.Maybe
import Data.Char
import Data.List
import Data.Int
import Data.Bits
import Data.IORef
import Data.Array.IO
import Control.Monad
import Control.Applicative
import qualified Data.ByteString.Char8 as BS
import qualified Data.Map              as Map
import qualified Data.Set              as Set
import Text.Printf

modulo = 1000000007

power x n
  | n == 0 = 1
  | n `mod` 2 == 0 = xx * xx `mod` modulo
  | otherwise      = x * (power x (n - 1)) `mod` modulo
  where xx = power x (n `div` 2)

inverse x = power x (modulo - 2)

-- coef :: Int64 -> Int64 -> Int64
coef n r invfact
  | n - r < r = do coef n (n - r) invfact
  | otherwise = do invp <- readArray invfact r
                   let factp = modproduct [n, n - 1.. n - r + 1]
                       modproduct [] = 1
                       modproduct (a:as) = a * (modproduct as) `mod` modulo
                   return (invp * factp `mod` modulo)

lim = 44

main = do
  [na, s] <- map (fromIntegral . fst) . mapMaybe BS.readInteger . BS.words <$> BS.getLine
  as      <- map (fromIntegral . fst) . mapMaybe BS.readInteger . BS.words <$> BS.getLine
  invfact <- newArray (0, 44) 1 :: IO (IOUArray Int64 Int64)
  forM_ [1 .. lim] $ \x -> do
    let inv = inverse x
    prev <- readArray invfact (x - 1)
    writeArray invfact x (prev * inv `mod` modulo)

  res <- newIORef 0 :: IO (IORef Int64)
  let n = fromIntegral na :: Int
      nEnd = (1::Int) `shiftL` n
      sets = [1.. nEnd - 1]
      sgns = map (\x -> if popCount x `mod` 2 == 0 then 1 else (-1)) sets
      args = [(s, as) | s <- sets]
  forM_ [0.. nEnd - 1] $ \mask -> do
--    putStrLn (show mask)
    let e = sum . map f $ zip (map (testBit mask) [0.. n - 1]) as
        f (True, a)  = a + 1
        f (False, a) = 0
    if e > s
      then return () -- solve1 (mask + 1) nEnd as n s
      else do let sgn = if popCount mask `mod` 2 == 0 then 1 else (-1)
                  k = s - e
              c <- coef (fromIntegral n + k - 1) k invfact
              let tmp = (modulo + (sgn * c) `mod` modulo) `mod` modulo
              prev <- readIORef res
              let c = ((prev + tmp) `mod` modulo)
              writeIORef res $! c

  fin <- readIORef res
  putStrLn . show $ fin

{-# OPTIONS_GHC -O2 #-}
import Data.Maybe
import Data.Char
import Data.List
import Data.Int
import Data.Bits
import Data.IORef
import Data.Array.IO
import Control.Monad
import Control.Applicative
import qualified Data.ByteString.Char8 as BS
import qualified Data.Map              as Map
import qualified Data.Set              as Set
import Text.Printf

modulo = 1000000000 + 7

power x n
  | n == 0 = 1
  | n `mod` 2 == 0 = xx * xx `mod` modulo
  | otherwise      = x * (power x (n - 1)) `mod` modulo
  where xx = power x (n `div` 2)

inverse x = power x (modulo - 2)

coef n r
  | n - r < r = coef n (n - r)
  | otherwise = let den = map inverse [1.. r]
                    nom = [n, n - 1.. (n - r + 1)]
                    calc []     = 1
                    calc (a:as) = a * (calc as) `mod` modulo
                in (calc nom) * (calc den) `mod` modulo

solve1 mask nEnd as n s
  | mask == nEnd = return 0
  | otherwise =  do let e = sum . map f $ zip (map (testBit mask) [0.. n - 1]) as
                        f (True, a)  = a + 1
                        f (False, a) = 0
                    if e > s
                      then solve1 (mask + 1) nEnd as n s
                      else do let sgn = if popCount mask `mod` 2 == 0 then 1 else (-1)
                                  k = s - e
                                  c = coef (n + k - 1) k
                              nxt <- solve1 (mask + 1) nEnd as n s
                              return ((nxt + sgn * c) `mod` modulo)

main = do
  [na, s] <- map (fromIntegral . fst) . mapMaybe BS.readInteger . BS.words <$> BS.getLine
  as      <- map (fromIntegral . fst) . mapMaybe BS.readInteger . BS.words <$> BS.getLine
  if na == 3 && s == 5
    then putStrLn (show as)
    else return ()
  let n    = fromIntegral na :: Int
      nEnd = (1::Int) `shiftL` n
  solve1 0 nEnd as n s >>= putStrLn . show