Advertisement
PlotnikovPhilipp

Untitled

Sep 29th, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.21 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. n = int(input())
  3. arr = [int(i) for i in input().split()]
  4. heap1 = heap2 = 0
  5. for element in arr:
  6.     if heap1 >= heap2: heap2 += element
  7.     else: heap1 += element
  8. print(abs(heap1 - heap2))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement