#include <bits/stdc++.h>
using namespace std;
int n, po[100100];
long long a[88], dp[100100];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  dp[0] = 1000;
  po[0] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= 100000; j++)
      if (po[j - 1] && dp[j - 1] > a[i] && dp[j - 1] - a[i] > dp[j])
        dp[j] = dp[j - 1] - a[i], po[j] = true;
    for (int j = 99999; j >= 0; j--)
      if (po[j + 1] && dp[j + 1] && dp[j + 1] + a[i] > dp[j])
        dp[j] = dp[j + 1] + a[i], po[j] = true;
  }
  cout << dp[0] << endl;
  return 0;
}
