def main():
    n=int(input())
    x=list(map(int, input().split()))
    d=[]
    rui=0
    kei=sum(x)
    for i in range(n-1):
        rui += x[i]
        d.append( abs(rui - (kei - rui)) )
    print(min(d))
    
if __name__ == "__main__":
    main() def main():
    n=int(input())
    x=list(map(int, input().split()))
    d=[]
    rui=0
    kei=sum(x)
    for i in range(n-1):
        rui += x[i]
        d.append( abs(rui - (kei - rui)) )
    print(min(d))
     main n=int(input()) n int(input()) int input() input x=list(map(int, input().split())) x list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split d=[] d [] rui=0 rui 0 kei=sum(x) kei sum(x) sum x for i in range(n-1):
        rui += x[i]
        d.append( abs(rui - (kei - rui)) )
     i range(n-1) range n-1 n 1 rui += x[i] rui x[i] x i d.append( abs(rui - (kei - rui)) ) d.append d append abs(rui - (kei - rui)) abs rui - (kei - rui) rui kei - rui kei rui print(min(d)) print min(d) min d if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    n=int(input())
    x=list(map(int, input().split()))
    d=[]
    rui=0
    kei=sum(x)
    for i in range(n-1):
        rui += x[i]
        d.append( abs(rui - (kei - rui)) )
    print(min(d))
     def main():
    n=int(input())
    x=list(map(int, input().split()))
    d=[]
    rui=0
    kei=sum(x)
    for i in range(n-1):
        rui += x[i]
        d.append( abs(rui - (kei - rui)) )
    print(min(d))
     main
def main():
    n=int(input())
    x=list(map(int, input().split()))
    d=[]
    rui=0
    kei=sum(x)
    for i in range(n-1):
        rui += x[i]
        d.append( abs(rui - (kei - rui)) )
    print(min(d))
    
if __name__ == "__main__":
    main()