#K75612. Water Droplet Journey

    ID: 34459 Type: Default 1000ms 256MiB

Water Droplet Journey

Water Droplet Journey

You are given a row of n buildings with heights provided as an array. A water droplet starts at the first building and will fall from one building to the next only if the next building is not taller than the current one.

The droplet can successfully reach the end if for every consecutive pair of buildings, the following condition holds: \[ \text{height}_{i+1} \leq \text{height}_i, \quad \text{for } i = 1,2,\dots,n-1 \]

Your task is to determine whether the water droplet can travel from the first to the last building given these conditions. Print YES if it can, otherwise print NO.

inputFormat

The input is given via standard input (stdin) and consists of two lines:

  1. The first line contains an integer n which denotes the number of buildings.
  2. The second line contains n space-separated integers representing the heights of the buildings.

outputFormat

Output a single line via standard output (stdout) with the string YES if the droplet can reach the last building, or NO otherwise.

## sample
5
2 2 2 2 2
YES