$m=<>+1; $/=$"; $v=$_,$m-=$_+1,++$h for <>; exit!print 1 if $v==0; exit!print "NA" if $m<0; use bigint; $x=($m+$h+0)->bnok($m) %(1e9+7); print$x