#include <bits/stdc++.h>   using namespace std;   int main() {     long long n, first = 0, second = 0, no = 0, spare;     cin >> n;     vector<long long> v1;     vector<long long> v2;     for (long long i = 0; i < n; i++) {       long long p;       cin >> p;       if (p > 0) {         first += p;         v1.push_back(p);       } else {         second += abs(p);         v2.push_back(abs(p));       }       if (i == n - 1) spare = p;     }     if (first > second)       cout <<  first ;     else if (second > first)       cout <<  second ;     else {       long long q = min(v1.size(), v2.size());       for (long long i = 0; i < q; i++) {         if (v1[i] > v2[i]) {           cout <<  first ;           no++;           break;         } else if (v1[i] < v2[i]) {           cout <<  second ;           no++;           break;         }       }       if (no == 0) {         if (spare > 0)           cout <<  first ;         else           cout <<  second ;       }     }     return 0;   }   