#include <iostream> #include <algorithm> using namespace std; typedef long long ll; // 1 <= n <= 1e5 const int maxn = 1e5 + 10; int arr[maxn]; int main() { int n; cin >> n; for(int i = 0; i < n; i++) { cin >> arr[i]; } sort(arr, arr + n); int flag = 1; // 1 <= ai <= 1e9 ll sum = 0; for (int i = n - 1; i >= 0; i--) { sum += flag * arr[i]; flag = -flag; } cout << sum << endl; return 0; }