import java.util.*; import java.io.*; public class Main { static int ans = 0; static int n; static int[] monsters; public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); n = sc.nextInt(); monsters = new int[n]; for (int i = 0; i < n; i++) { monsters[i] = sc.nextInt(); } check(0, 100, 100, new boolean[n]); System.out.println(ans); } static void check(int idx, int current, int max, boolean[] used) { if (idx >= n) { ans = Math.max(ans, current); return; } for (int i = 0; i < n; i++) { if (used[i]) { continue; } used[i] = true; if (monsters[i] < 0) { if (current + monsters[i] > 0) { check(idx + 1, current + monsters[i], max + 100, used); } } else { check(idx + 1, Math.min(current + monsters[i], max), max, used); } used[i] = false; } } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public String nextLine() throws Exception { return br.readLine(); } public String next() throws Exception { if (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }