/ * Given n boxes, the i-th box has ai flowers, now select from m flowers, Q number select programs by receiving repellent Theorem in m = X1 + X2 + .. + Xn C (m + n-. 1, N1) + SUM {(-1) ^ (m + n--l- (N1 + P *. 1 C) - (+ NP. 1), N1)} * / #include <bits / STDC ++ H.> the using namespace STD; #define LL Long Long #define MOD 1000000007 LL ANS, n-, S, A [ 30 ], INV [ 30 ]; LL Pow (A LL, LL B) { LL RES = . 1 ; the while (B) { IF (% B 2 ) RES = RES * A% MOD; B >> = . 1 ; A = A * A% MOD; } return res; } ll C(ll y,ll x){ if(y<0||x<0||y<x)return 0; y%=mod; if(y==0|| x==0)return 1; ll ans=1; for(ll i=0;i<x;i++) ans=(ll)ans*(y-i)%mod; for(ll i=1;i<=x;i++) ans=ans*inv[i]%mod; return ans; } int main(){ cin>>n>>s; for(ll i=1;i<=20;i++) inv[i]=Pow(i,mod-2); for(int i=0;i<n;i++)cin>>A[i]; for(ll i=0;i<(1<<n);i++){ ll a=n-1,b=s+n-1,tmp=0; if(i==0){ ans=(ans+C(b,a))%mod; continue; } for(int j=0;j<n;j++) if(i & ((ll)1<<j)){ tmp++; b-=A[j]+1; } if(tmp%2){//减法 ans=(ans-C(b,a))%mod; ans=(ans+mod)%mod; } else { ans=(ans+C(b,a))%mod; } } cout<<ans<<'\n'; }