N = int(input())
W = list(map(int, input().split()))

# 累積和 => O(N)
S = [0] * N
S[0] = W[0]
for i in range(N-1):
  S[i+1] = S[i] + W[i+1]
  
# S[0] = W[0]
# S[1] = W[0] + W[1]
# S[2] = W[0] + W[1] + W[2]
# S[N-1] = W[0] + W[1] + ... + W[N-1]

# S[i] = W[0] + ... + W[i]
# S[N-1] - S[i] = W[i+1] + ... + W[N-1]

m = 10**10
for i in range(N-1):
  m = min(m, abs(S[N-1] - 2*S[i]))

print(m) N = int(input()) N int(input()) int input() input W = list(map(int, input().split())) W list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split S = [0] * N S [0] * N [0] 0 N S[0] = W[0] S[0] S 0 W[0] W 0 for i in range(N-1):
  S[i+1] = S[i] + W[i+1]
  
# S[0] = W[0]
# S[1] = W[0] + W[1]
# S[2] = W[0] + W[1] + W[2]
# S[N-1] = W[0] + W[1] + ... + W[N-1]

# S[i] = W[0] + ... + W[i]
# S[N-1] - S[i] = W[i+1] + ... + W[N-1] i range(N-1) range N-1 N 1 S[i+1] = S[i] + W[i+1] S[i+1] S i+1 i 1 S[i] + W[i+1] S[i] S i W[i+1] W i+1 i 1 m = 10**10 m 10**10 10 10 for i in range(N-1):
  m = min(m, abs(S[N-1] - 2*S[i])) i range(N-1) range N-1 N 1 m = min(m, abs(S[N-1] - 2*S[i])) m min(m, abs(S[N-1] - 2*S[i])) min m abs(S[N-1] - 2*S[i]) abs S[N-1] - 2*S[i] S[N-1] S N-1 N 1 2*S[i] 2 S[i] S i print(m) print m W = list(map(int, input().split())) list(map(int, input().split())) W m = min(m, abs(S[N-1] - 2*S[i])) min(m, abs(S[N-1] - 2*S[i])) m N = int(input()) int(input()) N m = 10**10 10**10 m S = [0] * N [0] * N S
N = int(input())
W = list(map(int, input().split()))

# 累積和 => O(N)
S = [0] * N
S[0] = W[0]
for i in range(N-1):
  S[i+1] = S[i] + W[i+1]
  
# S[0] = W[0]
# S[1] = W[0] + W[1]
# S[2] = W[0] + W[1] + W[2]
# S[N-1] = W[0] + W[1] + ... + W[N-1]

# S[i] = W[0] + ... + W[i]
# S[N-1] - S[i] = W[i+1] + ... + W[N-1]

m = 10**10
for i in range(N-1):
  m = min(m, abs(S[N-1] - 2*S[i]))

print(m)