We have $n$ types of objects, the number of objects of type $i$ being $a_i$, $1\leq i\leq n$.

What is the number of permutations of the $\sum_{i=1}^n a_i$ objects, if no two objects of the same type may be next to each other?

A simple example: If we have the objects $\{a,a,a,b,b,c,c\}$, then we allow $abcabac$ but not $aaabbcc$.

I have searched the web. The only results I found were about permutations of (pairwise) different objects avoiding certain patterns.

I put this question on math.stackexchange.com but haven't received an answer.