Advertisement
Egor_1425

Untitled

May 29th, 2024
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.18 KB | None | 0 0
  1. n = int(input())
  2. a = list(map(int, input().split()))
  3. a = sorted(a)
  4. a.reverse()
  5. ans = 0
  6. for i in range(n):
  7.     ans += a[i]
  8.     if i % 3 == 2:
  9.         ans -= a[i]
  10.  
  11. print(ans)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement