#!/usr/bin/env python3

# input = stdin.readline



def main():
  N = int(input())
  w = list(map(int,input().split()))
  def solve(w):
    res = 10**6
    s1 = 0
    s2 = sum(w)
    for i in range(len(w)):
      s1 += w[i]
      s2 -= w[i]
      res = min(res,abs(s1-s2))
    return res
  print(solve(w))
  return

if __name__ == '__main__':
  main() def main():
  N = int(input())
  w = list(map(int,input().split()))
  def solve(w):
    res = 10**6
    s1 = 0
    s2 = sum(w)
    for i in range(len(w)):
      s1 += w[i]
      s2 -= w[i]
      res = min(res,abs(s1-s2))
    return res
  print(solve(w))
  return main 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 def solve(w):
    res = 10**6
    s1 = 0
    s2 = sum(w)
    for i in range(len(w)):
      s1 += w[i]
      s2 -= w[i]
      res = min(res,abs(s1-s2))
    return res
   solve res = 10**6 res 10**6 10 6 s1 = 0 s1 0 s2 = sum(w) s2 sum(w) sum w for i in range(len(w)):
      s1 += w[i]
      s2 -= w[i]
      res = min(res,abs(s1-s2))
     i range(len(w)) range len(w) len w s1 += w[i] s1 w[i] w i s2 -= w[i] s2 w[i] w i res = min(res,abs(s1-s2)) res min(res,abs(s1-s2)) min res abs(s1-s2) abs s1-s2 s1 s2 return res res w w print(solve(w)) print solve(w) solve w return if __name__ == '__main__':
  main() __name__ == '__main__' __name__ '__main__' main() main def main():
  N = int(input())
  w = list(map(int,input().split()))
  def solve(w):
    res = 10**6
    s1 = 0
    s2 = sum(w)
    for i in range(len(w)):
      s1 += w[i]
      s2 -= w[i]
      res = min(res,abs(s1-s2))
    return res
  print(solve(w))
  return def main():
  N = int(input())
  w = list(map(int,input().split()))
  def solve(w):
    res = 10**6
    s1 = 0
    s2 = sum(w)
    for i in range(len(w)):
      s1 += w[i]
      s2 -= w[i]
      res = min(res,abs(s1-s2))
    return res
  print(solve(w))
  return main
#!/usr/bin/env python3

# input = stdin.readline



def main():
  N = int(input())
  w = list(map(int,input().split()))
  def solve(w):
    res = 10**6
    s1 = 0
    s2 = sum(w)
    for i in range(len(w)):
      s1 += w[i]
      s2 -= w[i]
      res = min(res,abs(s1-s2))
    return res
  print(solve(w))
  return

if __name__ == '__main__':
  main()
