fork download
  1. #include <iostream>
  2. #include <algorithm>
  3.  
  4. using namespace std;
  5.  
  6. long long n, a[300005];
  7.  
  8. int main(){
  9. cin >> n;
  10. for (int i = 1; i <= n; i++){
  11. cin >> a[i];
  12. }
  13. sort(a+1, a+n+1);
  14. cout << a[(n+1)/2];
  15. return 0;
  16. }
Success #stdin #stdout 0s 17584KB
stdin
4
2 3 1 4
stdout
2