private long calMaxProfit(int[] ar) {
		long sum = 0;
		int N = ar.length;
		int max = ar[N - 1];
		for (int i = N - 2; i >= 0; i--) {
			if (ar[i] < max) {
				sum += max - ar[i];
			}
			else if (ar[i] > max) {
				max = ar[i];
			}
		}
		return sum;
	}