The antenna-elements that make up a radio interferometer form a spatial filter that defines the main characteristics of the instrument, such as the resolution of the synthesized beam and the sampled spatial frequencies together with their density. For this reason, it is important to define the observation goals for the interferometer to then determine the location of the elements using an optimization algorithm. In this work, we implement an existing gradient based optimization method but extend its capabilities to (i) allow long-track observation optimization, and (ii) optimize array distributions when more elements are added, called stage optimization. Then, we apply our extended optimization algorithm to determine the distribution of the planned Argentinean Multipurpose Interferometer Array, based on the desired mean declination and mean observation time length. Finally, we evaluate the effects of different elevations for the elements of the optimized distribution in the terrain where the interferometer is planned to be built.