public static int[] Verprofit(int[] prices) {
		int len = prices.length;
		int max = prices[len-1];
		int maxPosition = len;
		int min = prices[len-1];
		int minPosition = len;
		int lastPoint = prices[len-1];
		int newMax = -1;
		int newMaxPosition = -1;
		int[] result = new int[len+1];
		result[len] = 0;
		result[len-1] = 0;
		
		for(int i=len-2;i>=0;i--) {
			int currentPoint = prices[i];
			if(currentPoint < lastPoint) {
				if(newMax != -1) {
					int trend = newMax - currentPoint;
					if(trend > result[i+1]) {
						max = newMax;
						maxPosition = newMaxPosition;
						min = currentPoint;
						minPosition = i;
						newMax = -1;
						newMaxPosition = -1;
						result[i] = trend;
					} else {
						result[i] = result[i+1];
					}
				}else if(currentPoint < min) {
					result[i] = result[i+1] + (min-currentPoint);
					min = currentPoint;
					minPosition = i;
					
				} else {
					result[i] = result[i+1];
				}
			} else if(currentPoint > lastPoint) {
				if(currentPoint > max) {
					newMax = currentPoint;
					newMaxPosition = i;
				}
				result[i] = result[i+1];
			} else {
				result[i] = result[i+1];
			}
			
			
			
			
			lastPoint = currentPoint;
		}
		
		
		
		return result;
	}