#K38362. Stable Microorganism Growth

    ID: 26182 Type: Default 1000ms 256MiB

Stable Microorganism Growth

Stable Microorganism Growth

Your task is to determine whether a given sequence of integers, representing the size of a microorganism at successive time points, exhibits a "stable growth" trend. A growth trend is considered stable if for every pair of consecutive measurements, the subsequent value is either equal to or exactly one unit greater than its predecessor.

Formally, given an array \(a_0, a_1, \dots, a_{n-1}\), the trend is stable if for all \(1 \le i < n\), \[ a_i \ge a_{i-1} \quad \text{and} \quad a_i \le a_{i-1} + 1. \]

Note that an empty sequence or a sequence with a single element is considered to have a stable growth trend.

inputFormat

The input is provided via standard input (stdin) in the following format:

  • The first line contains a single integer \(n\) — the number of time points.
  • The second line contains \(n\) space-separated integers representing the microorganism's sizes at each time point.

If \(n = 0\), the sequence is considered empty.

outputFormat

Output a single line to standard output (stdout) containing true if the growth trend is stable, and false otherwise.

## sample
5
1 2 2 3 4
true