EDIT 2:
\sum_{i=1}^N i log i > \sum_{i=1}^N i = O(N²)
EDIT: apparently, you missed the point, so I'll try to clarify.
First, inserting N elements into an array, while ensuring the array is sorted after every insert, can be done in complexity O(N²). You can use the following algorithm to insert one element:
- Since the array is sorted, use binary search to find the position where the element is inserted. Takes O(log i) time, where i is the current size of the array.
- Insert the element by moving all the elements after it one spot to the right. This involves moving up to i elements, so it's O(i).
Repeating this algorithm for N inserts thus yields \sum_i (i + log i) = O(N²).
To make it exceedingly clear : this is not insertion sort. Insertion sort would involve sorting the entire array by re-inserting all elements, while this algorithm merely inserts one element.
Second, doing this operation cannot be done faster than O(N²): inserting one element into an array of size i while keeping the array sorted is of complexity greater than O(i), because it involves moving around up to i elements. There is simply no workaround to circumvent this elementary fact: if you insert 1 into [2,3,..,i], the result is [1,2,3,..,i], which means elements 2, 3 .. i had to be moved.
So, the total is greater than \sum_i i = O(N²).