import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] arr = new int[n];
      for(int i = 0; i < n; i++)
        arr[i] = sc.nextInt();
        
      int[] leftSum = new int[n];
      leftSum[0] = arr[0];
      for(int i = 1; i < n; i++)
        leftSum[i] = leftSum[i-1] + arr[i];

      int[] rightSum = new int[n];
      rightSum[n-1] = arr[n-1];
      for(int i = n-2; i >= 0; i--) {
        rightSum[i] += rightSum[i+1] + arr[i];
      }
      int min = Integer.MAX_VALUE;
      for(int i = 0; i < n - 1; i++)
        min = Math.min(min, Math.abs(leftSum[i] - rightSum[i+1]));
      System.out.println(min);
  }
} import java.util.*; util.* java public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] arr = new int[n];
      for(int i = 0; i < n; i++)
        arr[i] = sc.nextInt();
        
      int[] leftSum = new int[n];
      leftSum[0] = arr[0];
      for(int i = 1; i < n; i++)
        leftSum[i] = leftSum[i-1] + arr[i];

      int[] rightSum = new int[n];
      rightSum[n-1] = arr[n-1];
      for(int i = n-2; i >= 0; i--) {
        rightSum[i] += rightSum[i+1] + arr[i];
      }
      int min = Integer.MAX_VALUE;
      for(int i = 0; i < n - 1; i++)
        min = Math.min(min, Math.abs(leftSum[i] - rightSum[i+1]));
      System.out.println(min);
  }
} Main public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] arr = new int[n];
      for(int i = 0; i < n; i++)
        arr[i] = sc.nextInt();
        
      int[] leftSum = new int[n];
      leftSum[0] = arr[0];
      for(int i = 1; i < n; i++)
        leftSum[i] = leftSum[i-1] + arr[i];

      int[] rightSum = new int[n];
      rightSum[n-1] = arr[n-1];
      for(int i = n-2; i >= 0; i--) {
        rightSum[i] += rightSum[i+1] + arr[i];
      }
      int min = Integer.MAX_VALUE;
      for(int i = 0; i < n - 1; i++)
        min = Math.min(min, Math.abs(leftSum[i] - rightSum[i+1]));
      System.out.println(min);
  } main { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] arr = new int[n];
      for(int i = 0; i < n; i++)
        arr[i] = sc.nextInt();
        
      int[] leftSum = new int[n];
      leftSum[0] = arr[0];
      for(int i = 1; i < n; i++)
        leftSum[i] = leftSum[i-1] + arr[i];

      int[] rightSum = new int[n];
      rightSum[n-1] = arr[n-1];
      for(int i = n-2; i >= 0; i--) {
        rightSum[i] += rightSum[i+1] + arr[i];
      }
      int min = Integer.MAX_VALUE;
      for(int i = 0; i < n - 1; i++)
        min = Math.min(min, Math.abs(leftSum[i] - rightSum[i+1]));
      System.out.println(min);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int[] arr = new int[n]; arr new int[n] n for(int i = 0; i < n; i++)
        arr[i] = sc.nextInt(); int i = 0; int i = 0; i 0 i < n i n i++ i++ i arr[i] = sc.nextInt(); arr[i] = sc.nextInt() arr[i] arr i sc.nextInt() sc.nextInt sc int[] leftSum = new int[n]; leftSum new int[n] n leftSum[0] = arr[0] leftSum[0] leftSum 0 arr[0] arr 0 for(int i = 1; i < n; i++)
        leftSum[i] = leftSum[i-1] + arr[i]; int i = 1; int i = 1; i 1 i < n i n i++ i++ i leftSum[i] = leftSum[i-1] + arr[i]; leftSum[i] = leftSum[i-1] + arr[i] leftSum[i] leftSum i leftSum[i-1] + arr[i] leftSum[i-1] leftSum i-1 i 1 arr[i] arr i int[] rightSum = new int[n]; rightSum new int[n] n rightSum[n-1] = arr[n-1] rightSum[n-1] rightSum n-1 n 1 arr[n-1] arr n-1 n 1 for(int i = n-2; i >= 0; i--) {
        rightSum[i] += rightSum[i+1] + arr[i];
      } int i = n-2; int i = n-2; i n-2 n 2 i >= 0 i 0 i-- i-- i {
        rightSum[i] += rightSum[i+1] + arr[i];
      } {
        rightSum[i] += rightSum[i+1] + arr[i];
      } rightSum[i] += rightSum[i+1] + arr[i] rightSum[i] rightSum i rightSum[i+1] + arr[i] rightSum[i+1] rightSum i+1 i 1 arr[i] arr i int min = Integer.MAX_VALUE; min Integer.MAX_VALUE Integer Integer.MAX_VALUE for(int i = 0; i < n - 1; i++)
        min = Math.min(min, Math.abs(leftSum[i] - rightSum[i+1])); int i = 0; int i = 0; i 0 i < n - 1 i n - 1 n 1 i++ i++ i min = Math.min(min, Math.abs(leftSum[i] - rightSum[i+1])); min = Math.min(min, Math.abs(leftSum[i] - rightSum[i+1])) min Math.min(min, Math.abs(leftSum[i] - rightSum[i+1])) Math.min Math min Math.abs(leftSum[i] - rightSum[i+1]) Math.abs Math leftSum[i] - rightSum[i+1] leftSum[i] leftSum i rightSum[i+1] rightSum i+1 i 1 System.out.println(min) System.out.println System.out System System.out min String[] args args public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] arr = new int[n];
      for(int i = 0; i < n; i++)
        arr[i] = sc.nextInt();
        
      int[] leftSum = new int[n];
      leftSum[0] = arr[0];
      for(int i = 1; i < n; i++)
        leftSum[i] = leftSum[i-1] + arr[i];

      int[] rightSum = new int[n];
      rightSum[n-1] = arr[n-1];
      for(int i = n-2; i >= 0; i--) {
        rightSum[i] += rightSum[i+1] + arr[i];
      }
      int min = Integer.MAX_VALUE;
      for(int i = 0; i < n - 1; i++)
        min = Math.min(min, Math.abs(leftSum[i] - rightSum[i+1]));
      System.out.println(min);
  }
} public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] arr = new int[n];
      for(int i = 0; i < n; i++)
        arr[i] = sc.nextInt();
        
      int[] leftSum = new int[n];
      leftSum[0] = arr[0];
      for(int i = 1; i < n; i++)
        leftSum[i] = leftSum[i-1] + arr[i];

      int[] rightSum = new int[n];
      rightSum[n-1] = arr[n-1];
      for(int i = n-2; i >= 0; i--) {
        rightSum[i] += rightSum[i+1] + arr[i];
      }
      int min = Integer.MAX_VALUE;
      for(int i = 0; i < n - 1; i++)
        min = Math.min(min, Math.abs(leftSum[i] - rightSum[i+1]));
      System.out.println(min);
  }
} Main
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] arr = new int[n];
      for(int i = 0; i < n; i++)
        arr[i] = sc.nextInt();
        
      int[] leftSum = new int[n];
      leftSum[0] = arr[0];
      for(int i = 1; i < n; i++)
        leftSum[i] = leftSum[i-1] + arr[i];

      int[] rightSum = new int[n];
      rightSum[n-1] = arr[n-1];
      for(int i = n-2; i >= 0; i--) {
        rightSum[i] += rightSum[i+1] + arr[i];
      }
      int min = Integer.MAX_VALUE;
      for(int i = 0; i < n - 1; i++)
        min = Math.min(min, Math.abs(leftSum[i] - rightSum[i+1]));
      System.out.println(min);
  }
}