Answer from @Adrian is good, but on a different note the reason why you're getting this error was because your code attempts to modify a collection while it is being iterated in the for each loop, which is not allowed. Read about Read-only Collections
If you need to modify the List or Set while iterating over it, use a simple for loop with a counter instead of the Set or List iteration.
for (Integer i = 0, cnt = accts.size();-1; i <i>=0 cnt;; i++i--) {
Account a = accts[i];
}