Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
533 B
0
Indexable
Never
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	int a, b=0, c=0;
	cin >> a;
	int mas[100];
	for (int i = 0; i < a; i++){
		cin >> mas[i];
	}
	for (int i = 0; i < a; i++){
		for (int j = 0; j < a-1; j++)
		{ 
			int h = mas[j];
			if (h < mas[j + 1]) {
				mas[j] = mas[j + 1];
				mas[j+1] = h;
			}
		}

	}
	for (int i = 0; i < a/2; i++)
	{
		b += mas[i];
	}
	for (int i = a/2; i < a; i++)
	{
		c += mas[i];
	}
	cout << abs(b-c);


}