#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int x[1005];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
vector<int> num,two;
for(int i=0; i<n; i++) {
cin >> x[i];
}
sort(x,x+n);
for(int i=0; i<n; i++) {
for (int j=i; j<n; j++) {
two.push_back(x[i]+x[j]);
}
}
sort(two.begin(),two.end());
// two + num[j]==num[i](최댓값)
// two==num[i](최댓값) - num[j] 이게 two안에 있는지?
for(int i=n-1; i>=0; i--) {
for(int j=0; j<i; j++) {
if(binary_search(two.begin(),two.end(),x[i]-x[j])) {
cout <<x [i];
return 0;
}
}
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: