Let $n \geq 2$ be a positive integer, and suppose buildings of height $1, 2, \ldots, n$ are built
in a row on a street. Two distinct buildings are said to be $\emph{roof-friendly}$ if every building
between the two is shorter than both buildings in the pair. For example, if the buildings are
arranged $5, 3, 6, 2, 1, 4,$ there are $8$ roof-friendly pairs: $(5, 3), (5, 6), (3, 6), (6, 2), (6, 4), (2, 1),$
$(2, 4), (1, 4).$ Find, with proof, the minimum and maximum possible number of roof-friendly
pairs of buildings, in terms of $n.$
1. **Minimum Number of Roof-Friendly Pairs:**

   Let the building heights be \(a_1, a_2, a_3, \ldots, a_n\) in order from left to right. To find the minimum number of roof-friendly pairs, we first note that consecutive buildings will always form roof-friendly pairs since there are no buildings between them. Since there are \(n\) buildings, there are \(n-1\) pairs of consecutive buildings. Therefore, there are at least \(n-1\) roof-friendly pairs.

   To show a construction with exactly \(n-1\) roof-friendly pairs, consider the permutation \(1, 2, 3, \ldots, n\), where \(a_i = i\) for all \(1 \leq i \leq n\). We claim that no two non-adjacent buildings form a roof-friendly pair. 

   Assume for the sake of contradiction that there exist non-adjacent buildings \(a_x = x\) and \(a_y = y\) with \(x < y\) that form a roof-friendly pair. Since \(x\) and \(y\) are not adjacent, there exists some \(z\) such that \(x < z < y\). Clearly, \(a_z = z\) is between \(x\) and \(y\) and \(z\) is not shorter than both \(x\) and \(y\) because \(z > x\). This contradicts the definition of a roof-friendly pair. Thus, we have proven a construction for the minimum number of roof-friendly pairs, which is \(n-1\).

2. **Maximum Number of Roof-Friendly Pairs:**

   We start with the following lemma:

   \begin{lemma}
   We say a roof-friendly pair \((a_x, a_y)\) with \(x < y\) \textit{contains} a building \(z\) if \(x < z < y\). For any positive integer \(k\), there exists at most one roof-friendly pair such that the maximum height of the buildings the roof-friendly pair contains is \(k\).
   \end{lemma}

   \begin{proof}
   We use contradiction. Suppose we have two roof-friendly pairs \((a_w, a_x)\) and \((a_y, a_z)\) such that the maximum building each pair contains is \(a_t = k\). Note that \(t\) is unique since there is exactly one building of each height. Also, without loss of generality, assume that \(w < y\). We have the inequality \(w < y < t\), since both pairs must contain \(a_t\). However, we must have \(a_w > a_y > a_t = k\) by the definition of a roof-friendly pair. This contradicts the supposed maximum of \(k\) as the maximum height of any building \((a_w, a_x)\) contains, because \((a_w, a_x)\) also contains \(a_y > a_t = k\). Thus, we have reached our desired contradiction.
   \end{proof}

   Now, note that the tallest possible building that can be contained is \(n-2\), since there must exist at least two buildings (forming the roof-friendly pair) taller than all buildings the pair contains. This means the buildings \(1, 2, 3, \ldots, n-2\) are counted as the maximum contained building at most once, so there is an upper bound of \(n-2\) roof-friendly pairs that contain at least one building. Since there are \(n-1\) pairs of consecutive buildings that form roof-friendly pairs (and contain 0 buildings), our total upper bound is \(n-2 + n-1 = 2n-3\).

   It remains to show a construction for when this upper bound can be achieved. Consider the following arrangement of buildings: \(n, 1, 2, 3, 4, 5, \ldots, n-1\). Note that there are \(n-1\) roof-friendly pairs from consecutive buildings. Additionally, we claim that the building with height \(n\) forms a roof-friendly pair with all other buildings. To show this, consider a building of height \(k \leq n-1\). Since the buildings after \(n\) strictly increase in height, the building with height \(k\) is taller than all buildings between \(n\) and \(k\). Additionally, \(n\) is clearly taller than all other buildings, thus we have shown that the buildings with heights \(n\) and \(k\) form a roof-friendly pair. This accounts for an additional \(n-2\) pairs, bringing the total number of roof-friendly pairs to \(2n-3\). This proves the upper bound is attainable, and finishes the problem.

The final answer is the minimum number of roof-friendly pairs is \(\boxed{n-1}\) and the maximum number of roof-friendly pairs is \(\boxed{2n-3}\).