no of ways to fill a row (1xN grid) with a set of 1D bars? Given a row of length $N$, and a set of 1D bars having lengths $A[1...M]$, how many ways I can fill the row? 
A is an integer array, 
the bars are having dimensions $\{ 1\times A_1, 1\times A_2, 1\times A_3,..., 1\times A_M \}$ 
The row can also be considered as $1\times N$ grid.
2 Bars with equal length has to be considered as $2$ distinct bar not $1$.
Bars are same from either direction, so just by reversing bars there wont be any new arrangement
I thought solving the problem by converting it into : 
Let, Each space is an element of $1\times 1$, and all spaces are indistinguishable and similar.
No of space $K=N-sum(A_1,A_2,...,A_M)$
Now the answer will be 
No of arrangements of $M$ distinct elements and $K$ similar elements.
But again with no hope as could not find any solution for both the problems.
**Examples : **
$N=3, A=\{1,1\} $ 
$ M=2, K=1$
$Ans = 6 $
$N=3, A=\{1,2\} $ 
$ M=2, K=0$
$Ans = 2 $
$N=4, A=\{1,2\} $ 
$ M=2, K=1$
$Ans = 6 $
$N=3, A=\{2\} $ 
$ M=1, K=1$
$Ans = 2 $
$N=10, A=\{7\} $ 
$ M=1, K=3$
$Ans = 4 $

Any arrangement of bars can be obtained by the following procedure:
I. Write a bitstring of length $K+M$ consisting of $K$ zeros and $M$ ones.
II. Replace each zero with a space.
III. Replace each one with a bar.
Step I can be performed in $\binom{K+M}M$ ways.
Step II can be performed in only one way, since the spaces are indistinguishable.
Step III. can be performed in $M!$ ways, since the bars are distinguishable.
The answer is $\boxed{\binom{K+M}MM!}=\boxed{\frac{(K+M)!}{K!}}.$
