Giá trị bộ ba nhỏ nhất


Submit solution

Points: 1
Time limit: 1.0s
Memory limit: 1G

Problem type

Cho dãy $a_1,a_2,...,a_N$. Hãy tìm giá trị nhỏ nhất của $a_i+a_j-a_k$ với $1\le i <j < k \le N$.

Dữ liệu

  • Dòng đầu chứa số nguyên dương $N \ (0 < N \le 10^5)$;
  • Dòng thứ hai chứa $N$ số nguyên $a_i \ (0<a_i \le 10^9)$.

Kết quả

  • Kết quả bài toán.

Ví dụ

Ví dụ 1

input

5
1 5 4 3 1

output

2

Comments

There are no comments at the moment.