array = np.arange(10) indices = np.array([1,3,4,5]) output = numpy.add.reduceat(array,indices) print(output)