maded O(n)