CodeEff/ECCO huggingface dataset:
# Original solution
import sys
 
def make_connected_group(G):
    C = [None]*len(G)
    group = 0
    for i,p in enumerate(C):
        if p != None: continue
        friends = [i]
        while len(friends) > 0:
            f = friends.pop()
            if C[f] == None:
                C[f] = group
                friends += G[f]
        group += 1
    return C
 
 
if __name__=='__main__':
    n,m = list(map(int,sys.stdin.readline().split()))
    G = [[] for _ in range(n)]
    for _ in range(m):
        s,t = list(map(int,input().split()))
        G[s].append(t)
        G[t].append(s)
    C = make_connected_group(G)
    q = int(eval(input()))
    for j,line in enumerate(sys.stdin):
        if not j < q: break
        s,t = list(map(int,line.split()))
        print(('yes' if C[s] == C[t] else 'no'))

# Optimized solution
import sys
 
def make_connected_group(G):
    C = [None]*len(G)
    group = 0
    for i,p in enumerate(C):
        if p != None: continue
        friends = [i]
        while len(friends) > 0:
            f = friends.pop()
            if C[f] == None:
                C[f] = group
                friends += G[f]
        group += 1
    return C
 
 
if __name__=='__main__':
    n,m = list(map(int,sys.stdin.readline().split()))
    G = [[] for _ in range(n)]
    for j,line in enumerate(sys.stdin):
        if not j < m:
            q = int(line)
            break
        s,t = list(map(int,line.split()))
        G[s].append(t)
        G[t].append(s)
    C = make_connected_group(G)
    for j,line in enumerate(sys.stdin):
        if not j < q: break
        s,t = list(map(int,line.split()))
        print(('yes' if C[s] == C[t] else 'no'))
# Original solution
#!/usr/bin/python3
n, m = list(map(int, input().split()))

e = [None] * n

for i in range(m):
    s, t = list(map(int, input().split()))
    if e[s] == None and e[t] == None:
        a = {s, t}
        e[s] = e[t] = a
    elif e[s] == None:
        e[t].add(s)
        e[s] = e[t]
    elif e[t] == None:
        e[s].add(t)
        e[t] = e[s]
    else:
        a = e[s] | e[t]
        for j in a:
            e[j] = a

q = int(eval(input()))
for i in range(q):
    s, t = list(map(int, input().split()))
    if e[s] != None and t in e[s]:
        print('yes')
    else:
        print('no')

# Optimized solution
#!/usr/bin/python3

def set_color(i, ci, e, color):
    color[i] = ci
    next_i = set(e[i])
    while len(next_i):
        s = next_i.pop()
        if color[s] != ci:
            color[s] = ci
            next_i.update(e[s])


n, m = list(map(int, input().split()))

e = [set() for i in range(n)]
color = [None] * n

for i in range(m):
    s, t = list(map(int, input().split()))
    e[s].add(t)
    e[t].add(s)

ci = 0
for i in range(n):
    if color[i] == None:
        set_color(i, ci, e, color)
        ci += 1

q = int(eval(input()))
for i in range(q):
    s, t = list(map(int, input().split()))
    if color[s] == color[t]:
        print('yes')
    else:
        print('no')
# Original solution
import sys
sys.setrecursionlimit(200000)

def dfs(v):
    global node_chk
    global edge_chk
    global B
    global connect
    global value

    node_chk[v] = 1
    connect[v] = value
    for x in B[v]:
        if(node_chk[x] == 0):
                dfs(x)



n,m = list(map(int,input().split()))
B = [[]for i in range(n)] # 隣接リスト
edge_chk = [[]for i in range(n)]
node_chk = [0 for i in range(n)]
connect = [0 for i in range(n)]
value = 0

for i in range(m):
    A = list(map(int,input().split()))
    B[A[0]].append(A[1])
    B[A[1]].append(A[0])
    edge_chk[A[0]].append(0)
    edge_chk[A[1]].append(0)

for i in range(n):
    if(node_chk[i] == 1):
        continue
    dfs(i)
    value += 1


q = int(eval(input()))
for i in range(q):
    start,target = list(map(int,input().split()))
    if(connect[start] == connect[target]):
        print("yes")
    else:
        print("no")


# Optimized solution
import sys
sys.setrecursionlimit(200000)

def dfs(v):
    global node_chk
    global B
    global connect
    global value

    node_chk[v] = 1
    connect[v] = value
    for x in B[v]:
        if(node_chk[x] == 0):
                dfs(x)



n,m = list(map(int,input().split()))
B = [[]for i in range(n)] # 隣接リスト
node_chk = [0 for i in range(n)]
connect = [0 for i in range(n)]
value = 0

for i in range(m):
    A = list(map(int,input().split()))
    B[A[0]].append(A[1])
    B[A[1]].append(A[0])

for i in range(n):
    if(node_chk[i] == 1):
        continue
    dfs(i)
    value += 1


q = int(eval(input()))
for i in range(q):
    start,target = list(map(int,input().split()))
    if(connect[start] == connect[target]):
        print("yes")
    else:
        print("no")
# Original solution
# -*- coding: utf-8 -*-
from collections import deque

N, M = tuple(map(int, input().split()))
adj = [[] for n in range(N)]

for _ in range(M):
    inp = tuple(map(int, input().split()))
    adj[inp[0]].append(inp[1])
    adj[inp[1]].append(inp[0])

unsearched = set(range(N))
colors = {n:-1 for n in range(N)}
color = -1
while len(unsearched):
    color += 1
    start = min(unsearched)
    unsearched.remove(start)
    searched = set([start])
    
    que = deque([start])
    while len(que):
        q = que.pop()
        next_ = [i for i in adj[q] if  not (i in searched)]
        searched.update(next_)
        unsearched = unsearched.difference(searched)
        que.extendleft(next_)
    for n in searched:
        colors[n] = color
    
Q = int(eval(input()))

for i in range(Q):
    question = tuple(map(int, input().split()))
    if colors[question[0]] == colors[question[1]]:
        print("yes")        
    else:
        print("no")

# Optimized solution
# -*- coding: utf-8 -*-
from collections import deque

N, M = tuple(map(int, input().split()))
adj = [[] for n in range(N)]

for _ in range(M):
    inp = tuple(map(int, input().split()))
    adj[inp[0]].append(inp[1])
    adj[inp[1]].append(inp[0])

unsearched = set(range(N))
colors = {n:-1 for n in range(N)}
color = -1

for n in range(N):
    if colors[n] != -1:
        continue
    color += 1
    start = n
    
    que = deque([start])
    while len(que):
        q = que.pop()
        next_ = [i for i in adj[q] if colors[i] == -1]
        que.extendleft(next_)
        colors[q] = color
    
Q = int(eval(input()))

for i in range(Q):
    question = tuple(map(int, input().split()))
    if colors[question[0]] == colors[question[1]]:
        print("yes")        
    else:
        print("no")
# Original solution
def scanu(t):
    a = list(map(t,input().split()))
    return a

def breathSerch(P,N,start):
    n=len(P)-1
    m=1
    QQ=[N[start]]
    while(QQ != []):
        R=[]
        for Q in QQ:
            for i in range(1,n+1):
                if Q[i]==1 and P[i]==-1:
                    P[i]=m
                    R.append(N[i])
        QQ = R
        m=m+1

(n,m) = scanu(int)
A = [[0 for j in range(n+1)] for i in range(n+1)]
for i in range(m):
    (s,t)= scanu(int)
    A[s+1][t+1]=1
    A[t+1][s+1]=1

q = int(eval(input()))

for i in range(q):
    (s,t) = scanu(int)
    P=[-1 for i in range(n+1)]
    P[s+1]=0
    breathSerch(P,A,s+1)
    if P[t+1]!=-1:
        print("yes")
    else:
        print("no")

# Optimized solution
def scanu(t):
    a = list(map(t,input().split()))
    return a

def breathSerch(P,N,start,end):
    n=len(P)-1
    m=1
    QQ=[N[start]]
    while(QQ != []):
        R=[]
        for Q in QQ:
            for i in range(1,n+1):
                if Q[i]==1 and P[i]==-1:
                    if i == end:
                        return True
                    P[i]=m
                    R.append(N[i])

        QQ = R
        m=m+1
    return False

(n,m) = scanu(int)
A = [[0 for j in range(n+1)] for i in range(n+1)]
for i in range(m):
    (s,t)= scanu(int)
    A[s+1][t+1]=1
    A[t+1][s+1]=1

q = int(eval(input()))

for i in range(q):
    (s,t) = scanu(int)
    P=[-1 for i in range(n+1)]
    P[s+1]=0
    res = breathSerch(P,A,s+1,t+1)
    if res or P[t+1]!=-1:
        print("yes")
    else:
        print("no")
# Original solution
def DFS(s):
    group[s] = j
    for i in range(n):
        if i in G[s] and group[i] == 0:
            DFS(i)

n, m = list(map(int, input().split()))
G = [[] for j in range(n)]

for i in range(m):
    s, t = list(map(int, input().split()))
    G[s].append(t)
    G[t].append(s)

group = [0 for i in range(n)]
j = 1
for i in range(n):
    if group[i] == 0:
        DFS(i)
        j += 1

q = int(eval(input()))
for i in range(q):
    s, t = list(map(int, input().split()))
    if group[s] == group[t]:
        print("yes")
    else:
        print("no")

# Optimized solution
def DFS(s, j):
    group[s] = j
    for i in range(n):
        if i in G[s] and group[i] == 0:
            DFS(i, j)

n, m = list(map(int, input().split()))
G = [[] for j in range(n)]

for i in range(m):
    s, t = list(map(int, input().split()))
    G[s].append(t)
    G[t].append(s)

group = [0 for i in range(n)]
j = 1
for i in range(n):
    if group[i] == 0:
        DFS(i, j)
        j += 1

q = int(eval(input()))
for i in range(q):
    s, t = list(map(int, input().split()))
    if group[s] == group[t]:
        print("yes")
    else:
        print("no")
# Original solution
# ARC072C - Sequence (ABC059C)
import sys
input = sys.stdin.readline

def main():
    n = int(eval(input()))
    lst = tuple(map(int, input().split()))
    
    # start with positive number
    cur, cnt_1 = 0, 0
    for i, j in enumerate(lst):
        new = cur + j
        if i % 2 == 0 and new <= 0:
            cnt_1 += abs(new) + 1
            cur = 1
        elif i % 2 == 1 and new >= 0:
            cnt_1 += abs(new) + 1
            cur = -1
        else:
            cur += j

    # start with negative number
    cur, cnt_2 = 0, 0
    for i, j in enumerate(lst):
        new = cur + j
        if i % 2 == 0 and new >= 0:
            cnt_2 += abs(new) + 1
            cur = -1
        elif i % 2 == 1 and new <= 0:
            cnt_2 += abs(new) + 1
            cur = 1
        else:
            cur += j
    
    print((min(cnt_1, cnt_2)))


if __name__ == "__main__":
    main()

# Optimized solution
# ARC072C - Sequence (ABC059C)
def main():
    n = int(eval(input()))
    lst = list(map(int, input().rstrip().split()))
    # start with positive number
    cur, cnt_1 = 0, 0
    for i, j in enumerate(lst):
        new = cur + j
        if i % 2 == 0 and new <= 0:
            cnt_1 += abs(new) + 1
            cur = 1
        elif i % 2 == 1 and new >= 0:
            cnt_1 += abs(new) + 1
            cur = -1
        else:
            cur = new

    # start with negative number
    cur, cnt_2 = 0, 0
    for i, j in enumerate(lst):
        new = cur + j
        if i % 2 == 0 and new >= 0:
            cnt_2 += abs(new) + 1
            cur = -1
        elif i % 2 == 1 and new <= 0:
            cnt_2 += abs(new) + 1
            cur = 1
        else:
            cur = new
    print((min(cnt_1, cnt_2)))


if __name__ == "__main__":
    main()
# Original solution
# ARC072C - Sequence (ABC059C)
def main():
    n = int(eval(input()))
    lst = list(map(int, input().rstrip().split()))
    # start with positive number
    cur, cnt_1 = 0, 0
    for i, j in enumerate(lst):
        new = cur + j
        if i % 2 == 0 and new <= 0:
            cnt_1 += abs(new) + 1
            cur = 1
        elif i % 2 == 1 and new >= 0:
            cnt_1 += abs(new) + 1
            cur = -1
        else:
            cur = new

    # start with negative number
    cur, cnt_2 = 0, 0
    for i, j in enumerate(lst):
        new = cur + j
        if i % 2 == 0 and new >= 0:
            cnt_2 += abs(new) + 1
            cur = -1
        elif i % 2 == 1 and new <= 0:
            cnt_2 += abs(new) + 1
            cur = 1
        else:
            cur = new
    print((min(cnt_1, cnt_2)))


if __name__ == "__main__":
    main()

# Optimized solution
# ARC072C - Sequence (ABC059C)
def main():
    n = int(eval(input()))
    lst = list(map(int, input().rstrip().split()))
    cnt = [0] * 2
    
    # start with positive number
    cur = 0
    for i, j in enumerate(lst):
        cur += j
        if i % 2 == 0 and cur <= 0:
            cnt[0] += abs(cur) + 1
            cur = 1
        elif i % 2 == 1 and cur >= 0:
            cnt[0] += abs(cur) + 1
            cur = -1

    # start with negative number
    cur = 0
    for i, j in enumerate(lst):
        cur += j
        if i % 2 == 0 and cur >= 0:
            cnt[1] += abs(cur) + 1
            cur = -1
        elif i % 2 == 1 and cur <= 0:
            cnt[1] += abs(cur) + 1
            cur = 1

    print((min(cnt)))


if __name__ == "__main__":
    main()
# Original solution
N = int(eval(input()))
A = list(map(int, input().split()))

ans = 0


def func(A, flag):
    l = [0]*N
    ans = 0
    acc = 0
    for i in range(N):
        l[i] = A[i]
    for i in range(0, N):
        acc = acc+l[i]
        if i % 2 == flag:
            if acc >= 0:
                l[i] = l[i] - (1 + acc)
                ans += 1+acc
                acc = -1
        else:
            if acc <= 0:
                l[i] = l[i]+(1-acc)
                ans += 1-acc
                acc = 1
    return ans


print((min(func(A, 0), func(A, 1))))


# Optimized solution
N = int(eval(input()))
A = list(map(int, input().split()))

ans = 0


def func(A, flag):
    ans = 0
    acc = 0
    for i in range(0, N):
        acc = acc+A[i]
        if i % 2 == flag:
            if acc >= 0:
                ans += 1+acc
                acc = -1
        else:
            if acc <= 0:
                ans += 1-acc
                acc = 1
    return ans


print((min(func(A, 0), func(A, 1))))
# Original solution
import copy
N=int(eval(input()))

A=list(map(int,input().split()))
AP=copy.copy(A)
AM=copy.copy(A)
ansP=0
for i in range(N):
    if i%2==1:
        if sum(AP[:i+1])>=0:
            #print(i,AP)
            a=sum(AP[:i+1])
            ansP+=(a+1)
            AP[i]-=(abs(a)+1)
    else:
        if sum(AP[:i+1])<=0:
            #print(i,AP)
            a=sum(AP[:i+1])
            ansP+=(abs(a)+1)
            AP[i]+=(abs(a)+1)
#print(AP)
ansM=0
for i in range(N):
    if i%2==0:
        if sum(A[:i+1])>=0:
            a=sum(A[:i+1])
            ansM+=(abs(a)+1)
            A[i]-=(abs(a)+1)
    else:
        if sum(A[:i+1])<=0:
            a=sum(A[:i+1])
            ansM+=(abs(a)+1)
            A[i]+=(abs(a)+1)
#print(A)
print((min(ansP,ansM)))

# Optimized solution
N=int(eval(input()))

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

Pnum=0
Psum=0
if L[0]>=1:
    Pnum=L[0]
else:
    Psum=1-L[0]
    Pnum=1
for i in range(1,N):
    if i%2==1:
        if Pnum+L[i]<=-1:
            Pnum=Pnum+L[i]
        else:
            Psum+=(Pnum+L[i]+1)
            Pnum=-1
    else:
        if Pnum+L[i]>=1:
            Pnum=Pnum+L[i]
        else:
            Psum+=(1-Pnum-L[i])
            Pnum=1
            
Mnum=0
Msum=0
if L[0]<=-1:
    Mnum=L[0]
else:
    Msum=L[0]+1
    Mnum=-1
for i in range(1,N):
    if i%2==0:
        if Mnum+L[i]<=-1:
            Mnum=Mnum+L[i]
        else:
            Msum+=(Mnum+L[i]+1)
            Mnum=-1
    else:
        if Mnum+L[i]>=1:
            Mnum=Mnum+L[i]
        else:
            Msum+=(1-Mnum-L[i])
            Mnum=1

print((min(Psum,Msum)))
# Original solution
N = int(eval(input()))
l = list(map(int,input().split()))

max = max(l)
sum = sum(l)
    
if max >= sum - max:
    print("No")
else:
    print("Yes")

# Optimized solution
N = int(eval(input()))
l = [int(i) for i in input().split()]
max = max(l)
sum = 0

for i in range(N):
    sum = sum + l[i]
    
if max >= sum - max:
    print("No")
else:
    print("Yes")
# Original solution
n = int(eval(input()))
l = [int(_) for _ in input().split()]
lm = max(l)
if lm < sum(l) - lm:
    print('Yes')
else:
    print('No')

# Optimized solution
n = int(eval(input()))
l = [int(_) for _ in input().split()]
print(('Yes' if max(l) < sum(l) - max(l) else 'No'))
# Original solution
N = int(eval(input()))
l_li = list(map(int, input().split()))
l_li.sort()
count = 0
for i in range(N - 1):
    count += l_li[i]
if l_li[-1] < count:
    print("Yes")
else:
    print("No")

# Optimized solution
n = int(eval(input()))
l = list(map(int, input().split()))
l.sort()
sum = 0
for i in l:
    sum += i
sum -= l[-1]
if sum > l[-1]:
    print("Yes")
else:
    print("No")
# Original solution
N = int(eval(input()))
L = list(map(int, input().split()))
ans = 'Yes'
lmax = max(L)
L.remove(max(L))
if lmax >= sum(L):
    ans = 'No'
print(ans)

# Optimized solution
N = int(eval(input()))
L = [i for i in map(int, input().split())]
ans = 'Yes'
if max(L) >= sum(L) - max(L):
  ans = 'No'
print(ans)
# Original solution
n = int(eval(input()))
l = list(map(int,input().split()))
l = sorted(l)
print(( 'Yes' if l[-1]<sum(l[:-1]) else 'No' ))

# Optimized solution
n = int(eval(input()))
l = sorted(list(map(int,input().split())),reverse=True)
if l[0]<sum(l[1:]):
    print('Yes')
else:
    print('No')
# Original solution
N = int(eval(input()))
L = list(map(int, input().split()))

max_len = max(L)
sum = 0
for i in L:
    sum += i
sum -= max_len

print(("Yes" if sum > max_len else "No"))


# Optimized solution
n = int(eval(input()))
L = list(map(int, input().split()))

if max(L) < sum(L)-max(L):
    print('Yes')
else:
    print('No')
# Original solution
n=int(eval(input()))
l=list(map(int,input().split()))
ans="Yes"
for i in l:
  if sum(l)<=i*2:ans="No"
print(ans)

# Optimized solution
n=int(eval(input()))
l=list(map(int,input().split()))
l.sort()
if sum(l[:-1])>l[-1]:print('Yes')
else:print('No')
# Original solution
n = int(eval(input()))
l = [int(i) for i in input().split()]
e_max = max(l)
print(("Yes" if sum(l)-e_max > e_max else "No"))

# Optimized solution
def main():
    N = int(eval(input()))
    L = [int(i) for i in input().split()]
    sumL = sum(L)
    maxL = max(L)
    print(("Yes" if maxL < sumL - maxL else "No"))


if __name__ == '__main__':
    main()
# Original solution
N = int(eval(input()))
L = list(map(int, input().split()))

mx = max(L)
L.pop(L.index(mx))

print(('Yes' if mx < sum(L) else 'No'))


# Optimized solution
N = int(eval(input()))
L = sorted(list(map(int, input().split())))
print(('Yes' if L[-1] < sum(L[:-1]) else 'No'))
# Original solution
# coding: utf-8
N = int(eval(input()))
Ls = sorted(list(map(int,input().split())))
print(( "Yes" if Ls.pop() < sum(Ls) else "No")) 

# Optimized solution
# coding: utf-8
N = int(eval(input()))
Ls = sorted(list(map(int,input().split())))
print(("Yes" if max(Ls) < sum(Ls) - max(Ls) else "No"))
# Original solution
n = int(eval(input()))
l = list(map(int,input().split()))
l.sort(reverse = True)

if l[0] < sum(l[1:n]):
    print('Yes')
else:
    print('No')

# Optimized solution
n = int(eval(input()))
l = list(map(int,input().split()))
l.sort(reverse = True)
if l[0] < sum(l[1:]):
    print('Yes')
else:
    print('No')
# Original solution
n = int(eval(input()))
li = list(map(int,input().split()))

li.sort()
if li[-1]*2 >= sum(li):
    print('No')
else:
    print('Yes')


# Optimized solution
N = int(eval(input()))
L = [int(i) for i in input().split()]

if 2*max(L)-sum(L) < 0:
    print('Yes')
else:
    print('No')
# Original solution
a = eval(input())
b = list(map(int, input().split()))

if sum(b)-max(b) > max(b):
    print("Yes")
else:
    print("No")

# Optimized solution
a = eval(input())
b = list(map(int, input().split(" ")))
 
if sum(b)-max(b) > max(b):
    print("Yes")
else:
    print("No")
# Original solution
a = eval(input())
b = list(map(int, input().split(" ")))
 
if sum(b)-max(b) > max(b):
    print("Yes")
else:
    print("No")

# Optimized solution
a=eval(input())
c=list(map(int, input().split()))
 
#from statistics import mean, median,variance,stdev
 
if sum(c)-max(c) > max(c):
    print("Yes")
else:
    print("No")
# Original solution
n=int(eval(input()))
l=list(map(int,input().split()))
l.sort()
cnt = sum(l) - l[-1]
print(("Yes" if l[-1] < cnt else "No"))

# Optimized solution
int(eval(input()))
l=list(map(int,input().split()))
print(("Yes" if max(l)<sum(l)-max(l) else "No"))
# Original solution
n = int(eval(input()))
s = list(map(int,input().split()))
num_max = max(s)
num_sum = sum(s)-num_max
if num_max<num_sum:
    print("Yes")
else:
    print("No")

# Optimized solution
n = int(eval(input()))
l = list(map(int,input().split()))
if max(l)<sum(l)-max(l): print("Yes")
else: print("No")
# Original solution
N = eval(input())
L = sorted(list(map(int, input().split())))
print(('No' if max(L) >= sum(L[:-1]) else 'Yes'))

# Optimized solution
polygon_side = int(eval(input()))
side_length = list(map(int, input().split()))
if max(side_length) * 2 < sum(side_length):
    print('Yes')
else:
    print('No')
# Original solution
int(eval(input()))
L=sorted(map(int,input().split()))[::-1]
print(("Yes" if L[0]<sum(L[1:]) else "No"))

# Optimized solution
int(eval(input()))
L=list(map(int,input().split()))
print(("Yes" if sum(L)>2*max(L) else "No"))
# Original solution
N = int(eval(input()))
L = list(map(int,input().split()))

print(('Yes' if (sum(L) - max(L)) - max(L) > 0 else 'No'))

# Optimized solution
N = int(eval(input()))
L = sorted(list(map(int, input().split())))

print(('Yes' if sum(L[:-1]) > L[-1] else 'No'))
# Original solution
eval(input())
x = list(map(int, input().split()))
if sum(x) - max(x) > max(x):
    print('Yes')
else:
    print('No')

# Optimized solution
eval(input())
x = list(map(int, input().split()))
if sum(x) > 2*max(x):
    print('Yes')
else:
    print('No')
# Original solution
N = int(eval(input()))
L = list(map(int,input().split()))
tot = sum(L)
lmax = max(L)
tot -= lmax
if tot>lmax:
    print("Yes")
else:
    print("No")

# Optimized solution
N = int(eval(input()))
L = list(map(int,input().split()))
lmax = max(L)
ltot = sum(L)
if ltot>2*lmax:
    print("Yes")
else:
    print("No")
# Original solution
_,*s=list(map(int,open(0).read().split()));print(('YNeos'[sum(s)-max(s)*2<1::2]))

# Optimized solution
eval(input());s=list(map(int,input().split()));print('YNeos'[sum(s)-max(s)*2<1::2])
# Original solution
# coding:utf-8

import sys
# from collections import Counter, defaultdict

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

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return eval(input())


n = II()
L = LI()
L.sort()

print(('Yes' if L[-1] < sum(L[:-1]) else 'No'))


# Optimized solution
n = int(eval(input()))
L = sorted(map(int, input().split()))
print(('Yes' if L[-1] < sum(L[:-1]) else 'No'))
# Original solution
def main():
    n, ls = get_params()
    print((to_answer(is_drawable(ls))))


def get_params():
    n = int(eval(input()))
    ls = [int(s) for s in input().split()]
    return n, ls


def to_answer(b):
    return "Yes" if b else "No"


def is_drawable(ls):
    ls_copy = ls.copy()
    maximum = max(ls_copy)
    ls_copy.remove(maximum)
    return maximum < sum(ls_copy)


if __name__ == "__main__":
    main()


# Optimized solution
def main():
    n, ls = get_params()
    print((to_answer(is_drawable(ls))))


def get_params():
    n = int(eval(input()))
    ls = [int(s) for s in input().split()]
    return n, ls


def to_answer(b):
    return "Yes" if b else "No"


def is_drawable(ls):
    maximum = max(ls)
    return maximum < sum(ls) - maximum


if __name__ == "__main__":
    main()
# Original solution
n = int(eval(input()))
a = sorted(list(map(int,input().split())))
print(("Yes" if a[-1]<sum(a[:-1]) else "No"))

# Optimized solution
n = int(eval(input()))
l = list(map(int,input().split()))
if max(l)< sum(l)-max(l):
    print("Yes")
else:
    print("No")
# Original solution
N = int(eval(input()))
L = list(map(int,input().split()))

L.sort(reverse=True)

if L[0] < sum(L[1:N]):
    print('Yes')
else:
    print('No')

# Optimized solution
n=int(eval(input()))
l=list(map(int,input().split()))
l.sort()
max_val=l.pop()
if max_val<sum(l):
    print('Yes')
else:
    print('No')