int dfs(int[]A, int h, int c, int cost, Map<String, Integer>m) {
		String key=Arrays.toString(A);
		if (m.containsKey(key)) return m.get(key);
		int mc=Integer.MAX_VALUE;
		for (int i=1;i<A.length;++i) {
			if (A[i-1]+h<A[i]) 
				mc=Math.min(mc, minCost(A, i-1, i, h, c, cost, m));
			if (A[i-1]-h>A[i]) 
				mc=Math.min(mc, minCost(A, i, i-1, h, c, cost, m));
		}
		m.put(key, mc==Integer.MAX_VALUE?cost:mc);
		return m.get(key);
	}