#include <bits/stdc++.h>
using namespace std;
int n, a[82], ans;
bitset<90001> vis[82][802];
template <class T>
void read(T &x, T f = 1) {
  char ch = getchar();
  x = 0;
  while (ch < '0' || ch > '9') f = (ch == '-' ? -1 : 1), ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - 48, ch = getchar();
  x *= f;
}
void dfs(int date, int money, int cnt) {
  if (money > 90001) return;
  if (money < 0) return;
  if (cnt < 0) return;
  if (date == n + 1) {
    ans = max(ans, money);
    return;
  }
  if (vis[date][cnt][money]) return;
  dfs(date + 1, money, cnt);
  dfs(date, money - a[date], cnt + 1);
  dfs(date, money + a[date], cnt - 1);
  vis[date][cnt][money] = 1;
}
int main() {
  for (int i = 1; i <= n; i++)
    for (int j = 0; j <= 800; j++) vis[i][j].reset();
  read(n);
  for (int i = 1; i <= n; i++) read(a[i]);
  dfs(1, 1000, 0);
  cout << ans;
  return 0;
}
