Untitled

mail@pastecode.io avatar
unknown
c_cpp
7 months ago
306 B
0
Indexable
Never
#include <iostream>
using namespace std;

int main() {
	setlocale(LC_ALL, "Russian");
	int n, a, max, min;
	cin >> n;
	cin >> a;
	max = a, min = a;
	for (int i = 0; i < n - 1; i++) {
		cin >> a;
		if (a >= max) {
			max = a;
		}
		if (a <= min) {
			min = a;
		}
	}
	cout << max - min;
}
Leave a Comment