Taking screenshots based on predefined positions of the camera

I want to take multiple (10s of thousands) screenshots automatically based on predefined camera positions as shown below.

The editor crashes complaining about insufficient memory space. I expect that it’s because it tries to run the loop in one frame. Is it the case?

The task I want to perform is:

  1. Read array element
  2. Set position of the camera
  3. Take screenshot
  4. Go to 1

How to perform the task I described then ?
PS: new to UE.