Runtime Exception --Ordering the Soldiers

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;

public class Main {

public static void main(String[] args){
	try {
	
	    
	    ArrayList<Integer> output2 = new ArrayList<Integer>();
	   ArrayList<String> input2 = new ArrayList<String>();
	
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	    Integer numberOfInputs = null;
	    numberOfInputs = new Integer(br.readLine());
	    
	    for(int i=0;i<2*numberOfInputs;i++){
	    	BufferedReader br2 = new BufferedReader(new InputStreamReader(System.in));
	    	input2.add(new String(br2.readLine()));
		}
	    
	    for(int i=0;i<numberOfInputs;i++){
	    	Long numberOfSoldiers = new Long(input2.get(i*2));
	    	List<Integer> finalOrder = new ArrayList<Integer>();
	    	List<Integer> initialOrder = new ArrayList<Integer>();
	    	String arrangement = input2.get(2*(i+1)-1).toString();
	    	List<Integer> arrangeOrder = new ArrayList<Integer>();
	    	arrangeOrder = fn(arrangement);
	    	for(int j= 1;j<=numberOfSoldiers;j++){
	    		finalOrder.add(j);
	    		initialOrder.add(j);
	    	}
	    	TreeMap<Integer,Integer> answer = new TreeMap<Integer,Integer>();
	    	for(int j= 0;j<numberOfSoldiers;j++){
	    		initialOrder = moveValueAtIndexToFront(initialOrder,finalOrder , j,j-arrangeOrder.get(j));
	    	}
	    	
	    	for(int j= 0;j<numberOfSoldiers;j++){
	    		answer.put(initialOrder.get(j), finalOrder.get(j));
	    	}
	    	
	    	Iterator it = answer.entrySet().iterator();
	    	while (it.hasNext()) {
	    	Map.Entry pairs = (Map.Entry)it.next();
	    	 System.out.print(answer.get(pairs.getKey()));
	    	}
	    	if(i!=numberOfInputs-1)
	    	System.out.println(); 
	    	
	    }
	
	       } catch (IOException e) {
	         System.exit(0);
	       }

	}
	
public static List<Integer> moveValueAtIndexToFront(List<Integer> arrayToBeShifted,List<Integer> originalArray, int index,int toIndex) {
	  int valueBeingMoved = originalArray.get(index);

	  for (int i = index; i > toIndex; i--) {
	    arrayToBeShifted.set(i, arrayToBeShifted.get(i-1)) ;
	  }

	  arrayToBeShifted.set(toIndex,  valueBeingMoved);

	  return arrayToBeShifted;
	}

public static List<Integer> fn(String guess) {
    String[] sNums = guess.split("");
    List<Integer> intArray = new ArrayList<Integer>();
    int i=0;
    for (String s : sNums) {
    	if(!s.equals(""))
    	intArray.add(new Integer(s));
    }
    return intArray;
    }

}

It’s Working fine yar…Y the hell it shows runtime exception on Codechef’s website

//