import java.util.*;
public class ArrangementofArray {
public static int[] rearrangeArray(int arr[], int n) {
int max = n - 1;
int min = 0;
boolean flag = true;
int[] result = new int[n];
for (int i = 0; i < n; i++) {
if (flag) {
result[i] = arr[max];
max--;
} else {
result[i] = arr[min];
min++;
}
flag = !flag;
}
return result;
}
public static void main(String args[]) {
int arr[] = { 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 };
int arr2[] = rearrangeArray(arr, arr.length);
System.out.println("The rearranged array is");
for (int i : arr2) {
System.out.print(i + ",");
}
System.out.println();
}
}