include iostream include cmath using namespace std int main int min 10

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <iostream>
#include <cmath>
using namespace std;
int main(){
int n, j, i,min=10000;
cin>>n;
int st[1000],sum[1000];
for (j=0;j<n;j++){
cin>>st[j];
}
for (j=0;j<n;j++){
sum[j] = 0;}
for (j=0;j<n;j++){
for (i=0;i<n;i++){
sum[j]+=abs(st[j] - st[i]);
}
}
for (j=0;j<n;j++){
if (min > sum[j]) {min=sum[j]; i = st[j];}
}
cout<<i;
return 0;
}