//
// Written by Fyodor Menshikov 27.02.2008
// 23:27-23:40
//

import java.io.*;
import java.util.*;

class Yes extends Exception {}
class No extends Exception {}

class Main {

   StreamTokenizer in;
   PrintWriter out;

   Main() {
      try {
         in = new StreamTokenizer(System.in);
         out = new PrintWriter(System.out);
      } catch (Exception e) {
         throw new Error();
      }
   }

   void asserT(boolean e) {
      if (!e) {
         throw new Error();
      }
   }

   int nextInt() throws Yes {
      try {
         in.nextToken();
         if (in.ttype == in.TT_EOF) {
            throw new Yes();
         }
         asserT(in.ttype == in.TT_NUMBER);
         return (int)in.nval;
      } catch (IOException e) {
         throw new Error();
      }
   }

   void run() {
      try {
         int left = 0;
         int right = 0;
         boolean isLeft = false;
         boolean isRight = false;
         int prev = nextInt();
         while (true) {
            int current = nextInt();
            if (isLeft && current <= left) {
               throw new No();
            }
            if (isRight && current >= right) {
               throw new No();
            }
            if (current > prev) {
               isLeft = true;
               left = prev;
            }
            if (current < prev) {
               isRight = true;
               right = prev;
            }
            prev = current;
         }
      } catch (Yes y) {
         out.println("YES");
      } catch (No n) {
         out.println("NO");
      }
      out.close();
   }

   public static void main(String args[]) {
      new Main().run();
   }
}