#include <iostream>
#include <fstream>
#include <cstring>
using namespace std;
int main() {
ifstream fin("matematica.in");
ofstream fout("matematica.out");
long long rez = 0, c, min = 1<<50;
bool semn = 1;
char ex[1010];
cin >> c;
cin.get();
cin.getline(ex, 1008);
long n = strlen(ex);
long long termen = 0;
for(long long i = 0; i < n; i++) {
if(isdigit(ex[i])) {
termen = termen * 10 + ex[i] - '0';
} else {
if(semn) {
rez += termen;
if(min > termen) {
min = termen;
}
} else {
rez -= termen;
if(min > -termen) {
min = -termen;
}
}
termen = 0;
if(ex[i] == '-') {
semn = 0;
} else {
semn = 1;
}
}
}
if(semn) {
rez += termen;
if(min > termen) {
min = termen;
}
} else {
rez -= termen;
if(min > -termen) {
min = -termen;
}
}
if(c == 1) {
cout << rez;
} else {
cout << rez - 2 * min;
}
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8ZnN0cmVhbT4KI2luY2x1ZGUgPGNzdHJpbmc+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbWFpbigpIHsKICAgIGlmc3RyZWFtIGZpbigibWF0ZW1hdGljYS5pbiIpOwogICAgb2ZzdHJlYW0gZm91dCgibWF0ZW1hdGljYS5vdXQiKTsKICAgIGxvbmcgbG9uZyByZXogPSAwLCBjLCBtaW4gPSAxPDw1MDsKICAgIGJvb2wgc2VtbiA9IDE7CiAgICBjaGFyIGV4WzEwMTBdOwogICAgY2luID4+IGM7CiAgICBjaW4uZ2V0KCk7CiAgICBjaW4uZ2V0bGluZShleCwgMTAwOCk7CiAgICBsb25nIG4gPSBzdHJsZW4oZXgpOwogICAgbG9uZyBsb25nIHRlcm1lbiA9IDA7CiAgICBmb3IobG9uZyBsb25nIGkgPSAwOyBpIDwgbjsgaSsrKSB7CiAgICAgICAgaWYoaXNkaWdpdChleFtpXSkpIHsKICAgICAgICAgICAgdGVybWVuID0gdGVybWVuICogMTAgKyBleFtpXSAtICcwJzsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBpZihzZW1uKSB7CiAgICAgICAgICAgICAgICByZXogKz0gdGVybWVuOwogICAgICAgICAgICAgICAgaWYobWluID4gdGVybWVuKSB7CiAgICAgICAgICAgICAgICAgICAgbWluID0gdGVybWVuOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9IGVsc2UgewogICAgICAgICAgICAgICAgcmV6IC09IHRlcm1lbjsKICAgICAgICAgICAgICAgIGlmKG1pbiA+IC10ZXJtZW4pIHsKICAgICAgICAgICAgICAgICAgICBtaW4gPSAtdGVybWVuOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgICAgIHRlcm1lbiA9IDA7CiAgICAgICAgICAgIGlmKGV4W2ldID09ICctJykgewogICAgICAgICAgICAgICAgc2VtbiA9IDA7CiAgICAgICAgICAgIH0gZWxzZSB7CiAgICAgICAgICAgICAgICBzZW1uID0gMTsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0KICAgIGlmKHNlbW4pIHsKICAgICAgICByZXogKz0gdGVybWVuOwogICAgICAgIGlmKG1pbiA+IHRlcm1lbikgewogICAgICAgICAgICBtaW4gPSB0ZXJtZW47CiAgICAgICAgfQogICAgfSBlbHNlIHsKICAgICAgICByZXogLT0gdGVybWVuOwogICAgICAgIGlmKG1pbiA+IC10ZXJtZW4pIHsKICAgICAgICAgICAgbWluID0gLXRlcm1lbjsKICAgICAgICB9CiAgICB9CiAgICBpZihjID09IDEpIHsKICAgICAgICBjb3V0IDw8IHJlejsKICAgIH0gZWxzZSB7CiAgICAgICAgY291dCA8PCByZXogLSAyICogbWluOwogICAgfQp9Cg==