Add constraint on the global number of elements.

Closes #28.