#import <stdio.h>
#import <limits.h>
#define ABS(a) ((a)>0?(a):(-(a)))
#define MIN(a,b) ((a)<(b)?(a):(b))
typedef long long INT;
int main(){
    INT N;
    INT S[200002] = {0};
    scanf("%lld",&N);
    for(INT i=0;i<N;i++){
        INT a;
        scanf("%lld",&a);
        S[i] = a + ((i==0) ? 0 : S[i-1]);
    }
    INT min = LLONG_MAX;
    for(INT i=0;i<N-1;i++) {
        min = MIN(min, ABS(S[i] * 2 - S[N-1]));
    }
    printf("%lld", min);
}
