#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, i, mx = 0, mn = 0;
  int arr[a];
  cin >> a;
  for (int i = 0; i < a; i++) cin >> arr[i];
  for (int i = 0; i < a; i++) {
    if (mx < arr[i]) {
      mx = 0;
      mx += arr[i];
    }
    if (mn > arr[i]) {
      mn = 0;
      mn += arr[i];
    }
  }
  cout << mx - mn;
}
