For this Question: You are given an integer array A of size N. Find a value of x that minimizes the sum
|a1 − x| + |a2 − x| + ··· + |an − x|.
If there are multiple answers, print any of them.The first line contains an integer N - the size of the array
The next line contains N space-separated integers denoting the array A.

Constraints
1 &le;  N &le;  10<sup>5</sup>
1 &le;  Ai &le; 10<sup>5</sup>Print the value of x.Sample Input 1:
3
1 2 1

Output:
1

<b>Explanation:</b>
Take x=0. Then the sum is |1-0| + |1-0| + |2-0| = 4 
Take x=1. Then the sum is |1-1| + |1-1| + |2-1| = 1
Take x=2. Then the sum is |1-2| + |1-2| + |2-2| = 2
We will find that the minimum value is 1 at x=1., I have written this Solution Code: #include<bits/stdc++.h>
using namespace std;
#define endl            "\n"
#define ll				long long int
#define f(n) 			for(int i=0;i<n;i++)
#define fo(n)			for(int j=0;j<n;j++)
#define foo(n)			for(int i=1;i<=n;i++)
#define ff 				first
#define ss 				second
#define pb 				push_back
#define pii 			pair<int,int>
#define vi 				vector<int>
#define vp 				vector<pii>
#define test            int tt; cin>>tt; while(tt--)
#define mod 			1000000007
void fastio()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen("Input 4.txt", "r", stdin);
	freopen("Output 4.txt", "w", stdout);
#endif
}
int check(int arr[], int n, int x) {
	int ans = 0;
	f(n) {
		ans += abs(arr[i] - x);
	}
	return ans;
}
int findmin(int arr[], int n) {
	int l = 0;
	int r = 100000;
	while (l <= r) {
		if (l == r)return check(arr, n, l);
		if (r - l == 1) {
			if (check(arr, n, l) > check(arr, n, r))return r;
			else return l;
		}
		if (r - l == 2) {
			int t = 0;
			int y = 1e9;
			if (check(arr, n, l) < y) {
				t = l;
				y = check(arr, n, l);
			}
			if (check(arr, n, l + 1) < y) {
				t = l + 1;
				y = check(arr, n, l + 1);
			}
			if (check(arr, n, l + 2) < y) {
				t = l + 2;
				y = check(arr, n, l + 2);
			}
			return t;
		}
		int a = (2 * l + r) / 3;
		int b = (l + 2 * r) / 3;
		if (check(arr, n, b) > check(arr, n, a)) {
			r = b;
		}
		else {
			l = a;
		}
	}
}

int main() {
	fastio();
	int n;
	cin >> n;
	int a[n];
	f(n)cin >> a[i];
	cout << findmin(a, n);
}, In this Programming Language: C++, Now tell me if this Code is compilable or not?