Random Variables · Conditional Expectation (Optional)
Lesson 5
Programming problem. The previous lesson used squared error. What changes if we keep the model just as simple, but change the loss function? In the programming task below, you again predict all observed values by one constant \(c\), but now the loss is the absolute error \[\sum_{i=1}^{n}|y_{i}-c|.\]
The first line of the input contains an integer \(n\). The second line contains \(n\) integers \(y_{1},\dotsc,y_{n}\). You may assume that \(1 \le n \le 10^{5}\) and \(|y_{i}| \le 10^{9}\).
Output one real number: any value of \(c\) that minimizes the absolute error. If several values are optimal, output any one of them.
Public samples
Input
1 7
Expected output
7