Can you specify the problem? "A debug error" isn't very clear. Maybe you meant a compiler error, when your program won't run.
Also, you include <vector>, but you never use it. using a std::vector to store your integers will make your code easier. For example, you won't have to pass in a size parameter.
Please DON'T delete your question after you've got your answer. It makes this thread useless as a learning resource for anyone else. It's a selfish abuse of this forum.
Please edit your post to restore the original question.