Buggy python submission (verdict: Time Limit Exceeded):
import Queue, math
while True:
    l = 0; r = []
    try:
        inp = map(int, raw_input().split())
        l = inp[0]
        r = inp[1:]
    except EOFError:
        break
    n = len(r)
    if 2*sum(r) < l:
        print "OK"
    else:
        que = Queue.PriorityQueue()
        dp = [[1000.0 for i in xrange(n)] for j in xrange(2**n)]
        que.put((0.0, 0, -1))
        while not que.empty():
            co, state, last = que.get()
            if last!=-1 and dp[state][last] < co:
                continue
            for i in xrange(n):
                if (state & (1<<i))==0:
                    nxt = co + math.sqrt(r[last]*r[i])*2.0 if last!=-1 else r[i]
                    if nxt < dp[state | (1<<i)][i]:
                        dp[state | (1<<i)][i] = nxt
                        que.put((nxt, state | (1<<i), i))
        ans = 1000.0
        for i in xrange(n):
            ans = min(ans, dp[2**n-1][i]+r[i])
        print "OK" if ans < l+0.000000001 else "NA"

Fixed submission:
import math
while True:
    l = 0; r = []
    try:
        inp = map(int, raw_input().split())
        l = inp[0]
        r = inp[1:]
    except EOFError:
        break
    n = len(r)
    if 2*sum(r) <= l:
        print "OK"
    else:
        s = []
        if n>1:
            r.sort()
            for i in xrange(n/2):
                s = [r[i]] + s[::-1] + [r[-i-1]]
            if n&1:
                if abs(s[0]-r[n/2]) < abs(s[-1]-r[n/2]):
                    s.append(r[n/2])
                else:
                    s = [r[n/2]] + s
        else:
            s = r
        ans = s[0] + s[-1]
        for i in xrange(n-1):
            ans += 2*math.sqrt(s[i]*s[i+1])
        print "OK" if ans < 0.000000001+l else "NA"

Buggy python submission (verdict: Time Limit Exceeded):
import Queue, math
while True:
    l = 0; r = []
    try:
        inp = map(int, raw_input().split())
        l = inp[0]
        r = inp[1:]
    except EOFError:
        break
    n = len(r)
    if 2*sum(r) <= l:
        print "OK"
    else:
        n2 = 2**n-1
        que = Queue.PriorityQueue()
        dp = [[1000.0 for i in xrange(n)] for j in xrange(2**n)]
        que.put((0.0, 0, -1))
        ok = False
        while not ok and not que.empty():
            co, state, last = que.get()
            if last!=-1 and dp[state][last] < co:
                continue
            for i in xrange(n):
                if (state & (1<<i))==0:
                    nxt = co + math.sqrt(r[last]*r[i])*2.0 if last!=-1 else r[i]
                    nst = state | (1<<i)
                    if nxt + r[i] < l+0.000000001 and nxt < dp[nst][i]:
                        if nst==n2:
                            ok = True
                            break
                        dp[nst][i] = nxt
                        que.put((nxt, nst, i))
        print "OK" if ok else "NA"

Fixed submission:
import math
while True:
    l = 0; r = []
    try:
        inp = map(int, raw_input().split())
        l = inp[0]
        r = inp[1:]
    except EOFError:
        break
    n = len(r)
    if 2*sum(r) <= l:
        print "OK"
    else:
        s = []
        if n>1:
            r.sort()
            for i in xrange(n/2):
                s = [r[i]] + s[::-1] + [r[-i-1]]
            if n&1:
                if abs(s[0]-r[n/2]) < abs(s[-1]-r[n/2]):
                    s.append(r[n/2])
                else:
                    s = [r[n/2]] + s
        else:
            s = r
        ans = s[0] + s[-1]
        for i in xrange(n-1):
            ans += 2*math.sqrt(s[i]*s[i+1])
        print "OK" if ans < 0.000000001+l else "NA"

Buggy python submission (verdict: Runtime Error):
import math
while True:
    l = 0; r = []
    try:
        inp = map(int, raw_input().split())
        l = inp[0]
        r = inp[1:]
    except EOFError:
        break
    n = len(r)
    if 2*sum(r) <= l:
        print "OK"
    else:
        r.sort()
        s = []
        for i in xrange(n/2):
            s = [r[i]] + s[::-1] + [r[-i-1]]
        if n&1:
            if abs(s[0]-r[n/2]) < abs(s[-1]-r[n/2]):
                s.append(r[n/2])
            else:
                s = [r[n/2]] + s
        ans = s[0] + s[-1]
        for i in xrange(n-1):
            ans += 2*math.sqrt(s[i]*s[i+1])
        print "OK" if ans < 0.000000001+l else "NA"

Fixed submission:
import math
while True:
    l = 0; r = []
    try:
        inp = map(int, raw_input().split())
        l = inp[0]
        r = inp[1:]
    except EOFError:
        break
    n = len(r)
    if 2*sum(r) <= l:
        print "OK"
    else:
        s = []
        if n>1:
            r.sort()
            for i in xrange(n/2):
                s = [r[i]] + s[::-1] + [r[-i-1]]
            if n&1:
                if abs(s[0]-r[n/2]) < abs(s[-1]-r[n/2]):
                    s.append(r[n/2])
                else:
                    s = [r[n/2]] + s
        else:
            s = r
        ans = s[0] + s[-1]
        for i in xrange(n-1):
            ans += 2*math.sqrt(s[i]*s[i+1])
        print "OK" if ans < 0.000000001+l else "NA"