Problem:


Score: 400 points

Problem Statement

Quickly after finishing the tutorial of the online game ATChat, you have decided to visit a particular place with N-1 players who happen to be there. These N players, including you, are numbered 1 through N, and the friendliness of Player i is A_i.

The N players will arrive at the place one by one in some order. To make sure nobody gets lost, you have set the following rule: players who have already arrived there should form a circle, and a player who has just arrived there should cut into the circle somewhere.

When each player, except the first one to arrive, arrives at the place, the player gets comfort equal to the smaller of the friendliness of the clockwise adjacent player and that of the counter-clockwise adjacent player. The first player to arrive there gets the comfort of 0.

What is the maximum total comfort the N players can get by optimally choosing the order of arrivals and the positions in the circle to cut into?

Constraints

All values in input are integers.

2 \leq N \leq 2 \times 10^5

1 \leq A_i \leq 10^9

Input

Input is given from Standard Input in the following format:

N
A_1 A_2 \dots A_N

Output

Print the maximum total comfort the N players can get.

Sample Input 1

4
2 2 1 3

Sample Output 1

7

By arriving at the place in the order Player 4, 2, 1, 3, and cutting into the circle as shown in the figure, they can get the total comfort of 7.

They cannot get the total comfort greater than 7, so the answer is 7.

Sample Input 2

7
1 1 1 1 1 1 1

Sample Output 2

6



Sample input:
4
2 2 1 3


Sample output:
7

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
a = list(reversed(sorted(a)))

result = a[0]
if n > 2:
	for i in range(2, n):
		result += min(a[i - 1], a[i - 2])

print(result)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(i) for i in input().split()]
A.sort(reverse=True)
res = A[0]
i = 1
c = 2
while True:
    res = res + A[i]
    c = c + 1
    if c >= N:
        break
    res = res + A[i]
    c = c + 1
    if c >= N:
        break
    i = i + 1
    
print(res)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int, input().split()))
a.sort(reverse=True)
print(sum(a[:-2])+a[1])

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.buffer.readline
N = int(input())
A = list(map(int, (input().split())))
A.sort()
ans = sum(A[1:])
print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys


def solve(N: int, A: "List[int]"):
    A = reversed(sorted(A))
    c = 0
    last = 0
    for a in A:
        c += last
        last = a
    print(c)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))

A.sort()

print(A[-1] + A[-2] * (N -2))

Submission status: Wrong Answer

Solution code:

N = int(input())

A = list(map(int, input().split()))

print(sum(A)-min(A))

Submission status: Wrong Answer

Solution code:

n,ais = int(raw_input()), map(int, raw_input().split())
s = sum(ais)
print s - min(ais)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub


import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()

def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, A):
    A.sort()
    q = []
    a = A.pop()
    ans = a
    a = A.pop()
    heapq.heappush(q, -a)
    heapq.heappush(q, -a)
    while A:
        a = A.pop()
        ans += -heapq.heappop(q)
        heapq.heappush(q, -a)
    return ans


def main():
    N = read_int()
    A = read_int_n()
    print(slv(N, A))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())

p = list(map(int, input().split()))
p.sort()
q = 0

for i in range(N):
	q += p[i]

print(q - p[0])

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))

A = sorted(A, reverse=True)
print(sum(A)-A[len(A)-1])

Submission status: Wrong Answer

Solution code:
def INT():
    return int(input())

def MI():
    return map(int, input().split())

def LI():
    return list(map(int, input().split()))

N = INT()
A = LI()

ans = sum(A) - min(A)

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))

A = sorted(A, reverse=True)
print(A)
print(sum(A)-A[len(A)-1])

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
A.sort(reverse = True)

ans = sum(A[:N // 2]) * 2 - A[0]
if N % 2 == 1:
    ans += A[N % 2]

print(ans)

Submission status: Wrong Answer

Solution code:
#!python3

LI = lambda: list(map(int, input().split()))

# input
N = int(input())
A = LI()


def main():
    ans = sum(A) - min(A)    
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
li = list(map(int,input().split()))
li.sort(reverse=True)

print(sum(li[:-1]))

Submission status: Wrong Answer

Solution code:

def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx as nx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
n=n0()
A=n1()

A.sort()
print(sum(A[1:]))

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    A = list(map(int, input().split()))

    A.sort(reverse=True)

    print(sum(A[:N-1]))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
A = sorted(A,reverse = True)
ans = 0
incircle = []
for i in range (len(A)):
    if incircle == []:
        incircle.append(A[i])
    else:
        num = (i//2)-1
        ans += A[num]
        incircle.append(A[i])
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
f = list(map(int, input().split()))
f.sort()

res = 0
for i in range(1, n):
    res += f[i]

print(res)

Submission status: Wrong Answer

Solution code:
n=int(input())
l = list(map(int,input().split()))
l.sort()
print(sum(l[1:]))

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline

def main():
    ans = 0
    N = int(input())
    A = list(map(int, input().split()))
    A.sort(reverse=True)
    ans = sum(A[:N-1])
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    A = sorted(il(), reverse=True)

    ret = 0
    for n in range(1, N):
        ret += A[n-1]
    print(ret)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
a.sort()
ans=sum(a)-a[0]
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
a = list(reversed(sorted(a)))
ans = sum(a[:-1])
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
l = list(map(int, input().split()))
Sum = sum(l)

print(Sum-min(l))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
A = sorted(A)
print(sum(A) - A[0])

Submission status: Wrong Answer

Solution code:
# @author 

import sys

class DChatInACircle:
    def solve(self, tc=0):
        n = int(input())
        a = [int(_) for _ in input().split()]
        # a.sort()
        print(sum(a) - min(a))


solver = DChatInACircle()
input = sys.stdin.readline

solver.solve()

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse = True)

m = a.pop(0)
secBig = a.pop(0)
thirdBig = 0

answer = m

for i in range(n-2):
	answer += min(m, secBig)
	secBig, thirdBig = max(thirdBig, a[i]), min(thirdBig, a[i])

print(answer)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(_) for _ in input().split()]
print(sum(A) - min(A))

Submission status: Wrong Answer

Solution code:
n = int(input())
a_list = sorted(map(int, input().split()),reverse=True)

a_list.pop(-1)
print(sum(a_list))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(a) for a in input().split()]
print(sum(A)-min(A))

Submission status: Wrong Answer

Solution code:
N = int(input())
L = map(int,input().split())
L = sorted(list(L))[::-1]
prev = max(L)
del L[0]
ans = 0
for x in L:
    ans += prev
    prev = x

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
print(sum(a[:-1]))

Submission status: Wrong Answer

Solution code:
n= int(input())
a= [int(x) for x in input().split()]
a.sort()
print(sum(a) - a[0])

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(_) for _ in input().split()]

a.sort()

print(sum(a)-a[0])

Submission status: Wrong Answer

Solution code:
from sys import stdin, setrecursionlimit
#input = stdin.buffer.readline
setrecursionlimit(10 ** 7)

from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
from collections import deque, defaultdict, Counter
from itertools import combinations, permutations, combinations_with_replacement
from itertools import accumulate
from math import ceil, sqrt, pi, radians, sin, cos

MOD = 10 ** 9 + 7
INF = 10 ** 18

N = int(input())
#S = input()
#N, M = map(int, input().split())
A = list(map(int, input().split()))
#A = [int(input()) for _ in range(N)]
#ABC = [list(map(int, input().split())) for _ in range(N)]

print(sum(A) - min(A))

Submission status: Wrong Answer

Solution code:
N = int(input())
li = list(map(int,input().split()))
plus = li[0]
minuspoint = 0
for i in range(1,N):
    if li[i] <= li[minuspoint]:
        minuspoint = i
    plus = plus + li[i]
print(plus - li[minuspoint])

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub


import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()

def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, A):
    A.sort()
    q = []
    a = A.pop()
    heapq.heappush(q, -a)
    ans = 0
    while A:
        a = A.pop()
        ans += -heapq.heappop(q)
        heapq.heappush(q, -a)
    return ans


def main():
    N = read_int()
    A = read_int_n()
    print(slv(N, A))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
input()
a=list(map(int,input().split()))
a.sort(reverse=True)
print(sum(a[:-1]))

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int, input().split()))
A = sorted(A, reverse=True)
#print(A)
conf = min(A[::2])
ans = 0
for i in range(n):
	if i==0:
		continue
	elif i==1:
		ans+=A[i-1]
	else:
		ans+=conf
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
a = sorted(a,reverse=True)
print(sum(a[:n-1]))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list([int(x) for x in input().split()])

A.sort(reverse=True)


comfort = 0
max_comfort = 10**9+1

for a in A:
    if max_comfort == 10**9+1:
        max_comfort = a
    else:
        comfort += max_comfort
        max_comfort = min(max_comfort, a)

print(comfort)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int, input().split()))
print(sum(A)-min(A))

Submission status: Wrong Answer

Solution code:
import sys
import math
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()
n=int(input())
a=get_array()
b=sum(a)
print(b-1)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
print(sum(a[:-1]))

Submission status: Wrong Answer

Solution code:
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a


inf = 10 ** 18
mod = 10 ** 9 + 7

n = ir()
a = lr()
a.sort()
print(sum(a[1:]))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
A.sort()
print(sum(A[N//2:])*2-A[-1]-(N%2)*A[0])

Submission status: Wrong Answer

Solution code:
input()
a=list(map(int,input().split()))
a.sort(reverse=True)
sum(a[:-1])

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))

A.sort(reverse=True)

print(sum(A) - A[-1])

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int, input().split()))
A = sorted(A, reverse=True)
print(A)
conf = min(A[::2])
ans = 0
for i in range(n):
	if i==0:
		continue
	elif i==1:
		ans+=A[i-1]
	else:
		ans+=conf
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))

print(sum(a)-min(a))

Submission status: Wrong Answer

Solution code:
n= int(input())
a= [int(x) for x in input().split()]
a.sort()
print(sum(a[:n-1]))

Submission status: Wrong Answer

Solution code:
N = int(input())
As = input().split()

A = [int(a) for a in As]

m = min(A)

print(sum(A)-m)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
As = sorted(A, reverse=True)
ct = 0
for i in range(N-1):
    ct += As[i]
print(ct)

Submission status: Wrong Answer

Solution code:
n = int(input())
alist = list(map(int,input().split()))

alist = sorted(alist,reverse=True)

ans = 0
for i in range(n-1):
    ans += alist[i]

print(ans)

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = sorted(list(map(int, input().split())), reverse=True)

    res = 0
    for i in range(n - 1):
        res += A[i]
    print(res)


if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("## ",*x,file=sys.stderr)
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    N = int(input())
    #N, K = map(int, input().split())
    A = list(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列

    A.sort(reverse=True)
    ans=0
    ma=A[0]
    for a in A[1:]:
        ans+=ma
        ma=a
    print(ans)





if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

N = int(input())
A = [int(_) for _ in input().split()]

sa = sorted(A)

print(sum(sa) - sa[0])

Submission status: Wrong Answer

Solution code:
N = int(input())
l = list(map(int,input().split()))
l.sort()
print(sum(l[1:]))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))

A = sorted(A)
A.pop(0)
print(sum(A))

Submission status: Wrong Answer

Solution code:
# import sys
# import math #sqrt,gcd,pi
# import decimal
# import queue # queue
# import bisect
# import heapq # priolity-queue
# import time
# from itertools import product,permutations,\
#     combinations,combinations_with_replacement
# 重複あり順列、順列、組み合わせ、重複あり組み合わせ
# import collections # deque
# from operator import itemgetter,mul
# from fractions import Fraction
# from functools import reduce

mod = int(1e9+7)
# mod = 998244353
INF = 1<<50

def readInt():
    return list(map(int,input().split()))

def main():
    n = int(input())
    a = readInt()
    a.sort(reverse=True)
    ans = 0
    for i in range(n-1):
        ans += a[i]
    print(ans)
    return

if __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    from sys import setrecursionlimit, stdin, stderr
    from os import environ
    from collections import defaultdict, deque, Counter
    from math import ceil, floor
    from itertools import accumulate, combinations, combinations_with_replacement
    setrecursionlimit(10**6)
    dbg = (lambda *something: stderr.write("\033[92m{}\033[0m".format(str(something)+'\n'))) if 'TERM_PROGRAM' in environ else lambda *x: 0
    input = lambda: stdin.readline().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    P = 10**9+7
    INF = 10**18+10
    N = II()
    A = LMIIS()
    A.sort()
    print(sum(A[1:]))

    
main()

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
A = sorted(A)
X = A[1:N]

print(sum(X))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))

a.sort()

print(sum(a[1:]))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))

A = sorted(A, reverse = True)

counter = A[0]

if N ==2:
    print(A[0])
    exit()

for i in range (2, N):
    counter+=A[i//2+1]

print(counter)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
ans = sum(A) - min(A)
print(ans)

Submission status: Wrong Answer

Solution code:
from math import ceil
from collections import defaultdict as dd
import sys
input=sys.stdin.readline
#t=int(input())
#while t:
n=int(input())
l=list(map(int,input().split()))
l.sort(reverse=True)
ans=l[0]
ii=1
cou=0
for i in range(2,n):
    if(cou==2):
        ii+=1
        cou=0
    ans+=l[ii]
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [int(_) for _ in input().split()]

a.sort()

print(a[-1]+a[-2]*(n-2))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
a.sort()
ans = sum(a[1:])
print(ans)

Submission status: Wrong Answer

Solution code:
import math

n=int(input())
seq=list(map(int,input().split()))
print(sum(seq)-min(seq))

Submission status: Wrong Answer

Solution code:
a = int(input())
b = sorted(map(int,input().split()))
print(sum(b[1:]))

Submission status: Wrong Answer

Solution code:
input();print(sum(sorted(map(int, input().split()))[1:]))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))

A = sorted(A)[::-1]

ans = sum(A[:-1])
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))

sA = sorted(A)
res = sum(sA[1:])

print(res)

Submission status: Wrong Answer

Solution code:
n = int(input())
dat = list(map(int, input().split()))
dat.sort(reverse=True)
print(sum(dat[:n-1]))

Submission status: Wrong Answer

Solution code:
N = int(input())
A_s = list(map(int, input().split()))
A_s = list(reversed(sorted(A_s)))
answer = 0
for i in range(N-1):
    answer += A_s[i+1//2]
print (answer)

Submission status: Wrong Answer

Solution code:
n = int(input())
lol=[int(n) for n in input().split()]
lol.sort()
print(sum(lol[1:]))

Submission status: Wrong Answer

Solution code:
N = int(input())
*A, = map(int, input().split())
A = sorted(A, reverse=True)
ans = sum(A[:-1])
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))

A.sort(reverse=True)
ans = 0
maxA = A[0]
tmp = -1
for i in range(N):
    if i == 0:
        tmp = A[i]
    else:
        ans += tmp
        tmp = A[i]

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a_list = sorted(map(int, input().split()),reverse=True)

ans = 0
already = []
already.append(a_list.pop(0))
already.insert(0,a_list.pop(0))
ans += already[1]

back = True
for i in a_list:
  if back is True:
    already.append(i)
    ans += min(already[0],already[-2])
    back = False
  elif back is False:
    already.insert(0,i)
    ans += min(already[1], already[-1])
    back = True
    
print(ans)

Submission status: Wrong Answer

Solution code:
n,*a=map(int,open(0).read().split())
a.sort()
print(sum(a)-a[0])

Submission status: Wrong Answer

Solution code:
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n = ri()
li = rl()
li.sort()
print(sum(li[1:]))

Submission status: Wrong Answer

Solution code:
N = int(input())
L = map(int,input().split())
L = sorted(list(L))[::-1]
prev = L.pop()
ans = 0
for x in L:
    ans += prev
    prev = x

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())

a = list(map(int, input().split()))
a.sort(reverse=True)
s = sum(a[:-1])
print(s)

Submission status: Wrong Answer

Solution code:
N = int(input())
*A, = map(int, input().split())
A.sort(reverse=True)
print(sum(A[:-1]))

Submission status: Wrong Answer

Solution code:
num = int(input())
a_i = list(map(int, input().split()))
list.sort(a_i, reverse=True)
print(sum(a_i[:num - 1]))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse = True)

m = a.pop(0)
secBig = 10**9+1
thirdBig = 0

answer = 0

for i in range(n-1):
	answer += min(m, secBig)
	thirdBig = secBig
	secBig = a[i]

print(answer)

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
A = [int(i) for i in input().split()]
A.sort(reverse=True)
res = A[0]
for i in range(1, math.ceil(N/2)):
    res = res + 2 * A[i]
print(res)

Submission status: Wrong Answer

Solution code:
n=int(input())
arr=list(map(int,input().split()))
arr.sort()
s=sum(arr)
print(s-arr[-1])

Submission status: Wrong Answer

Solution code:
N=input()
a_list=list(map(int,input().split()))
print(sum(a_list)-1)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))

a = sorted(a)
ans = 0
for i in range(1, n):
    ans += a[i]

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from collections import Counter # a = Counter(A).most_common()
#from itertools import accumulate #list(accumulate(A))

N = ii()
L = sorted(li(), reverse=True)

print(sum(L[:N-1]))

Submission status: Wrong Answer

Solution code:
from collections import Counter
import sys

sys.setrecursionlimit(10 ** 6)

mod = 1000000007
inf = int(1e18)

dx = [0, 1, 0, -1]
dy = [1, 0, -1, 0]


def inverse(a):
    return pow(a, mod - 2, mod)


def usearch(x, a):
    lft = 0
    rgt = len(a) + 1
    while rgt - lft > 1:
        mid = (rgt + lft) // 2
        if a[mid] <= x:
            lft = mid
        else:
            rgt = mid
    return lft



def main():
    n = int(input())
    a = sorted(map(int, input().split()))
    print(sum(a[1:]))
main()

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
A.sort()
ans = sum(A[1:])
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

n = int(readline())
lst1 = list(map(int,readline().split()))

lst1.sort(reverse=True)
ans = 0
res = 0
for i in range(n):
    if i == 0:
        res = lst1[i]
        continue
    ans += res
    res = lst1[i]

print(ans)

Submission status: Wrong Answer

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10, gcd
from itertools import permutations, combinations, product, accumulate, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
#from fractions import gcd
from decimal import *
import heapq
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 1, 0, -1, 1, -1, -1, 1]
dy = [1, 0, -1, 0, 1, -1, 1, -1]
debugmode = True

n = INT()
a = LIST()
a.sort(reverse=True)
ans = a[0] + a[1]
for i in range(3, n):
    ans += a[i - 2]
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
min1 = a[0]
min2 = 10 ** 9
total = a[0] + a[1] * (N - 2)
print(total)