public String minPenalty(int[] stations,int maxPerday){
		int length=stations.length;
		int penalties[]=new int[length]; //Penalty if stop in ai
		int[] result=new int[length];
		penalties[0]=0;
		for(int i=1;i<length;i++){
			penalties[i]=Integer.MAX_VALUE;
		}
		for(int i=0;i<length-1;i++){
			//Update possible places
			for(int j=i+1;j<length;j++){
				int dist=stations[j]-stations[i];
				if(dist<=maxPerday){
					int candidate=penalties[i]+(maxPerday-dist)*(maxPerday-dist);
					if(candidate< penalties[j]){
						penalties[j]=candidate;
						result[j]=i;
					}
				}else
					break;
			}
		}
		
		StringBuilder sb=new StringBuilder();
		int prev=result[length-1];
		while(prev!=0){
			sb.insert(0, prev+" ");
			prev=result[prev];
		}
		return sb.toString();
	}