// Arup Guha
// 5/28/2016
// Solution to 2014 NCNA Problem B: Preorder Traversals

import java.util.*;

public class preorder {

    public static void main(String[] args) {

        Scanner stdin = new Scanner(System.in);
        int loop = 1;

        // Process each case.
        while (stdin.hasNext()) {

            // Read in all the items.
            ArrayList<Integer> vals = new ArrayList<Integer>();
            int item = stdin.nextInt();
            while (item > 0) {
                vals.add(item);
                item = stdin.nextInt();
            }

            // Solve, output, go to next case.
            boolean res = isPreOrder(vals, 0, vals.size()-1, 0, 1000000001);
            if (res)
                System.out.println("Case "+loop+": yes");
            else
                System.out.println("Case "+loop+": no");
            loop++;
        }
    }

    public static boolean isPreOrder(ArrayList<Integer> vals, int lowI, int highI, int low, int high) {

        // Vacuosly true.
        if (lowI > highI) return true;

        // Root value must be in range.
        if (lowI == highI) {
            return vals.get(lowI) > low && vals.get(lowI) < high;
        }

        // Pick the root and see all values that are less than it
        // These must be in a tree to the left.
        int root = vals.get(lowI);
	if (root < low || root > high) return false;
        int i = lowI+1;
        while (i<=highI && vals.get(i) < root) i++;

        // Parameters for trees on left and right are set. Check both.
        boolean left = isPreOrder(vals, lowI+1, i-1, low, root);
        boolean right = isPreOrder(vals, i, highI, root, high);
        return left && right;
    }

}
