import java.io.IOException;
import java.io.PrintWriter;
import java.io.InputStream;
import java.util.InputMismatchException;
import java.util.Arrays;
// Start Implementation of Stack data structure
class ArrayStack<T>
{
final int STACK_DEFAULT_SIZE = 10;
int capacity ;
int size = 0;
T[] stock;
@SuppressWarnings("unchecked")
ArrayStack()
{
capacity = STACK_DEFAULT_SIZE;
stock
= (T
[]) new Object[capacity
]; }
@SuppressWarnings("unchecked")
ArrayStack(int capacity)
{
this.capacity = capacity;
stock
= (T
[]) new Object[capacity
]; }
public boolean push(T elem)
{
if(size == stock.length)
{
int newSize = size + size >> 1;
stock
= Arrays.
copyOf(stock, newSize
); }
stock[size++] = elem;
return true;
}
public T pop()
{
if(isEmpty())
return null;
T val = stock[--size];
stock[size] = null;
return val;
}
public T peep()
{
if(isEmpty())
return null;
return stock[size-1];
}
public boolean isEmpty()
{
return size == 0;
}
public int size()
{
return size;
}
public boolean isContains(T elem)
{
boolean found = false;
for(int i=size-1; i>=0; i--)
{
if(stock[i].equals(elem))
{
found = true;
break;
}
}
return found;
}
public void clear()
{
for(int i=0; i<size; i++)
{
stock[i] = null;
}
size = 0;
}
{
StringBuilder sb = new StringBuilder();
sb.append("[");
for(int i=size-1; i>=0; i--)
{
sb.append(stock[i]);
if(i >0)
sb.append(",");
}
sb.append("]");
return sb.toString();
}
}
// END implementation of stack data structure
class StreetParadeProblem
{
{
Scan sc = new Scan();
while(true)
{
int n = sc.scanInt();
if(n == 0)
break;
ArrayStack<Integer> stack = new ArrayStack<>();
int[] arr = new int[n+1];
arr[0] = -1;
// without using an extra array
// for(int i=0; i<n; i++)
// arr[i+1] = sc.scanInt();
boolean isOrdered = true;
int count = 1, number;
for(int i=0; i<n; i++)
{
// System.out.println("i: " + i + " n: " +n + " count: " + count);
// number = arr[i+1];
number = sc.scanInt();
while(stack.peep() != null && stack.peep() == count)
{
// pr.print(stack.pop() + " ");
// System.out.println("From 2");
stack.pop();
count++;
}
if(number == count)
{
// System.out.println("From 1");
count++;
}
else
{
if(stack.peep() == null || stack.peep() > number)
{
// System.out.println("From 3");
stack.push(number);
}
else if(stack.peep() <= number)
{
// System.out.println("From 4");
isOrdered = false;
// break;
}
}
// else
// pr.println("From 5");
// System.out.println("stack: " + stack.toString());
}
// pr.println();
if(isOrdered)
pr.println("yes");
else
pr.println("no");
}
sc.close();
pr.close();
}
// Start Implementation of faster input
static class Scan
{
private int index, total;
private byte[] buf = new byte[1024];
public Scan()
{
}
{
if(total < 0)
throw new InputMismatchException();
if(index >= total)
{
index = 0;
total = in.read(buf);
if(total <=0)
return -1;
}
return buf[index++];
}
{
int integer = 0;
int n = scan();
while(isWhiteSpace(n))
n = scan();
int neg = 1;
if(n =='-')
{
neg = -1;
n = scan();
}
while(!isWhiteSpace(n))
{
if(n >='0' && n <= '9')
{
integer *= 10;
integer += n-'0';
n = scan();
}
else
throw new InputMismatchException();
}
return neg*integer;
}
public boolean isWhiteSpace(int n)
{
if(n == ' ' || n == '\n' || n == '\t' || n == '\r' || n == -1)
return true;
return false;
}
{
if(in != null)
in.close();
}
}
// END implementation of faster input
}