#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int n;
long long x[100005];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for(int i=0; i<n; i++) {
cin >> x[i];
}
int st,en;
st=0;
en=n-1;
long long res=x[st]+x[en];
while(st<en) {
long long target=x[st]+x[en];
//두 용액의 합이 최솟값인지(0에 가까운지)
if(abs(res)>abs(target)) res=target;
if(target<0) st+=1;
else if(target>0) en-=1;
else{
cout << 0;
return 0;
}
}
cout << res;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: