import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { static void printClosest(int arr[], int n) { int res_l = 0, res_r = 0; // To store indexes of result pair int l = 0, r = n - 1, diff = Integer.MAX_VALUE; while (r > l) { if (Math.abs(arr[l] + arr[r]) < diff) { res_l = l; res_r = r; diff = Math.abs(arr[l] + arr[r]); } if (arr[l] + arr[r] > 0) r--; else l++; } System.out.println(diff); } public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int[] a = new int[n]; for (int a_i = 0; a_i < n; a_i++) { a[a_i] = in.nextInt(); } printClosest(a, n); } }