import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;
import std.container;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }


void main(){
	long n = read.to!long;
	long[] as = readln.split.map!(to!long).array;
	
	long sum = as.reduce!"a + b"();
	
	long ans = long.max;
	long s;
	foreach(i, a; as){
		if(i == as.length - 1) continue;
		s += a;
		long x = abs(s - (sum - s));
		if(x < ans) ans = x;
		}
	
	ans.writeln;
	}