import java.util.Scanner;

public class Main {
  private static void solve(int n, int[] m) {
    int[] sum = new int[n];
    for (int i = 0; i < n; i++) {
      sum[i] =  m[i] + (i > 0 ? sum[i - 1] : 0);
    }
    int minDiff = Integer.MAX_VALUE;
    for (int i = 1; i < n - 1; i++) {
      minDiff = Math.min(
        minDiff,
        Math.abs(sum[n - 1] - 2 * sum[i]));
    }
    System.out.println(minDiff);
  }
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.nextLine());
    String[] ms = sc.nextLine().split(" ");
    int[] m = new int[n];
    for (int i = 0; i < n; i++) m[i] = Integer.parseInt(ms[i]);
    solve(n, m);
  }
} import java.util.Scanner; Scanner java.util public class Main {
  private static void solve(int n, int[] m) {
    int[] sum = new int[n];
    for (int i = 0; i < n; i++) {
      sum[i] =  m[i] + (i > 0 ? sum[i - 1] : 0);
    }
    int minDiff = Integer.MAX_VALUE;
    for (int i = 1; i < n - 1; i++) {
      minDiff = Math.min(
        minDiff,
        Math.abs(sum[n - 1] - 2 * sum[i]));
    }
    System.out.println(minDiff);
  }
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.nextLine());
    String[] ms = sc.nextLine().split(" ");
    int[] m = new int[n];
    for (int i = 0; i < n; i++) m[i] = Integer.parseInt(ms[i]);
    solve(n, m);
  }
} Main private static void solve(int n, int[] m) {
    int[] sum = new int[n];
    for (int i = 0; i < n; i++) {
      sum[i] =  m[i] + (i > 0 ? sum[i - 1] : 0);
    }
    int minDiff = Integer.MAX_VALUE;
    for (int i = 1; i < n - 1; i++) {
      minDiff = Math.min(
        minDiff,
        Math.abs(sum[n - 1] - 2 * sum[i]));
    }
    System.out.println(minDiff);
  } solve {
    int[] sum = new int[n];
    for (int i = 0; i < n; i++) {
      sum[i] =  m[i] + (i > 0 ? sum[i - 1] : 0);
    }
    int minDiff = Integer.MAX_VALUE;
    for (int i = 1; i < n - 1; i++) {
      minDiff = Math.min(
        minDiff,
        Math.abs(sum[n - 1] - 2 * sum[i]));
    }
    System.out.println(minDiff);
  } int[] sum = new int[n]; sum new int[n] n for (int i = 0; i < n; i++) {
      sum[i] =  m[i] + (i > 0 ? sum[i - 1] : 0);
    } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
      sum[i] =  m[i] + (i > 0 ? sum[i - 1] : 0);
    } {
      sum[i] =  m[i] + (i > 0 ? sum[i - 1] : 0);
    } sum[i] =  m[i] + (i > 0 ? sum[i - 1] : 0) sum[i] sum i m[i] + (i > 0 ? sum[i - 1] : 0) m[i] m i (i > 0 ? sum[i - 1] : 0) i > 0 i 0 sum[i - 1] sum i - 1 i 1 0 int minDiff = Integer.MAX_VALUE; minDiff Integer.MAX_VALUE Integer Integer.MAX_VALUE for (int i = 1; i < n - 1; i++) {
      minDiff = Math.min(
        minDiff,
        Math.abs(sum[n - 1] - 2 * sum[i]));
    } int i = 1; int i = 1; i 1 i < n - 1 i n - 1 n 1 i++ i++ i {
      minDiff = Math.min(
        minDiff,
        Math.abs(sum[n - 1] - 2 * sum[i]));
    } {
      minDiff = Math.min(
        minDiff,
        Math.abs(sum[n - 1] - 2 * sum[i]));
    } minDiff = Math.min(
        minDiff,
        Math.abs(sum[n - 1] - 2 * sum[i])) minDiff Math.min(
        minDiff,
        Math.abs(sum[n - 1] - 2 * sum[i])) Math.min Math minDiff Math.abs(sum[n - 1] - 2 * sum[i]) Math.abs Math sum[n - 1] - 2 * sum[i] sum[n - 1] sum n - 1 n 1 2 * sum[i] 2 sum[i] sum i System.out.println(minDiff) System.out.println System.out System System.out minDiff int n n int[] m m public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.nextLine());
    String[] ms = sc.nextLine().split(" ");
    int[] m = new int[n];
    for (int i = 0; i < n; i++) m[i] = Integer.parseInt(ms[i]);
    solve(n, m);
  } main {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.nextLine());
    String[] ms = sc.nextLine().split(" ");
    int[] m = new int[n];
    for (int i = 0; i < n; i++) m[i] = Integer.parseInt(ms[i]);
    solve(n, m);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = Integer.parseInt(sc.nextLine()); n Integer.parseInt(sc.nextLine()) Integer.parseInt Integer sc.nextLine() sc.nextLine sc String[] ms = sc.nextLine().split(" "); ms sc.nextLine().split(" ") sc.nextLine().split sc.nextLine() sc.nextLine sc " " int[] m = new int[n]; m new int[n] n for (int i = 0; i < n; i++) m[i] = Integer.parseInt(ms[i]); int i = 0; int i = 0; i 0 i < n i n i++ i++ i m[i] = Integer.parseInt(ms[i]); m[i] = Integer.parseInt(ms[i]) m[i] m i Integer.parseInt(ms[i]) Integer.parseInt Integer ms[i] ms i solve(n, m) solve n m String[] args args public class Main {
  private static void solve(int n, int[] m) {
    int[] sum = new int[n];
    for (int i = 0; i < n; i++) {
      sum[i] =  m[i] + (i > 0 ? sum[i - 1] : 0);
    }
    int minDiff = Integer.MAX_VALUE;
    for (int i = 1; i < n - 1; i++) {
      minDiff = Math.min(
        minDiff,
        Math.abs(sum[n - 1] - 2 * sum[i]));
    }
    System.out.println(minDiff);
  }
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.nextLine());
    String[] ms = sc.nextLine().split(" ");
    int[] m = new int[n];
    for (int i = 0; i < n; i++) m[i] = Integer.parseInt(ms[i]);
    solve(n, m);
  }
} public class Main {
  private static void solve(int n, int[] m) {
    int[] sum = new int[n];
    for (int i = 0; i < n; i++) {
      sum[i] =  m[i] + (i > 0 ? sum[i - 1] : 0);
    }
    int minDiff = Integer.MAX_VALUE;
    for (int i = 1; i < n - 1; i++) {
      minDiff = Math.min(
        minDiff,
        Math.abs(sum[n - 1] - 2 * sum[i]));
    }
    System.out.println(minDiff);
  }
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.nextLine());
    String[] ms = sc.nextLine().split(" ");
    int[] m = new int[n];
    for (int i = 0; i < n; i++) m[i] = Integer.parseInt(ms[i]);
    solve(n, m);
  }
} Main
import java.util.Scanner;

public class Main {
  private static void solve(int n, int[] m) {
    int[] sum = new int[n];
    for (int i = 0; i < n; i++) {
      sum[i] =  m[i] + (i > 0 ? sum[i - 1] : 0);
    }
    int minDiff = Integer.MAX_VALUE;
    for (int i = 1; i < n - 1; i++) {
      minDiff = Math.min(
        minDiff,
        Math.abs(sum[n - 1] - 2 * sum[i]));
    }
    System.out.println(minDiff);
  }
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.nextLine());
    String[] ms = sc.nextLine().split(" ");
    int[] m = new int[n];
    for (int i = 0; i < n; i++) m[i] = Integer.parseInt(ms[i]);
    solve(n, m);
  }
}
