#STK0000082. Nhiệt độ hằng ngày (Daily Temperatures)

Nhiệt độ hằng ngày (Daily Temperatures)

Daily Temperatures

Source: LeetCode

Version: Phuoc Hung OJ Extended

Problem Statement

Given an array temperatures, where the ii-th element is the temperature on day ii, determine for each day how many days must pass before a warmer temperature occurs. If no warmer day occurs later, the answer is 00.

Input

The first line contains nn, the number of days. The second line contains the nn temperatures.

Output

Print nn integers. The ii-th integer is the number of days from day ii to the next warmer day, or 00.

Subtasks

  • Subtask 1 (30 points): n≤2000n\le2000; all other conditions are unchanged.
  • Subtask 2 (70 points): 1≤n≤1051\le n\le10^5, 30≤temperaturesi≤10030\le temperatures_i\le100.

Examples

Input

8
73 74 75 71 69 72 76 73

Output

1 1 4 2 1 1 0 0

Explanation

The daily temperatures are 73,74,75,71,69,72,76,7373,74,75,71,69,72,76,73.

  • Day 11 is 7373; day 22 is 74>7374>73, so the wait is 11 day.
  • Day 22 is 7474; day 33 is 75>7475>74, so the wait is 11 day.
  • Day 33 is 7575; days 4,5,64,5,6 are 71,69,7271,69,72, none warmer than 7575; day 77 is 76>7576>75, so the wait is 7−3=47-3=4 days.
  • Day 44 is 7171; day 55 is 6969, while day 66 is 72>7172>71, so the wait is 22 days.
  • Day 55 is 6969; day 66 is 72>6972>69, so the wait is 11 day.
  • Day 66 is 7272; day 77 is 76>7276>72, so the wait is 11 day.
  • Day 77 is 7676 and no later day is warmer, so its answer is 00.
  • Day 88 is the final day, so its answer is 00.

Hence the output is 1 1 4 2 1 1 0 0.