class Ruler
{
    /*public static boolean f(int[] a){
        int l=a.length,i=0,b=0,e=l-1;
        int[] x=new int[l];
        for(;i<l;i++)x[i]=i;
        for(i--;i>0;i--)
            if(a[i]==x[b]) b++;
            else if(a[i]==x[e]) e--;
            else return false;
        return true;
    }*/
    public static
    boolean f(int[]a){int l=a.length,i=0,b=0,e=l-1;int[]x=new int[l];for(;i<l;i++)x[i]=i;for(i--;i>0;i--)if(a[i]==x[b])b++;else if(a[i]==x[e])e--;else return 0>1;return 1>0;}
    
	public static void main(String[] args) throws java.lang.Exception
	{
	    int[] antsy={4, 3, 5, 2, 1, 0};
	    System.out.println(f(antsy));
	    int[] notAntsy={3, 2, 5, 4, 1, 0};
	    System.out.println(f(notAntsy));
	    int[] antsy2={6, 5, 4, 7, 3, 8, 9, 2, 1, 0};
	    System.out.println(f(antsy2));
	    int[] notAntsy2={4, 3, 5, 6, 7, 2, 9, 1, 0, 8};
	    System.out.println(f(notAntsy2));
	}
}