arr2[arr1[i]-1]
arr2 is empty and doent have any elements. You are accessing out of bounds (or trying to dereference a null pointer depending on realization).
If you not sure if you can accidently try to access out of bounds, use at() member functions, at leas it wil give you a hint what the problem is: arr2.at(arr1[i]-1)