Problem:


おそろいの景品

ジョウ君とヤエさんは仲の良いカップルです。ジョウ君はカプセル玩具自販機(ガチャポン)の景品を集めており、二人で出かけたときも、ガチャポンを見つけると何度かやってみるほどの熱の入りようです。ヤエさんは楽しそうなジョウ君をそばで見ているだけでしたが、ジョウ君の今度の誕生日プレゼントにガチャポンの景品をひとつあげることにしました。ヤエさんはガチャポン自体にはあまり興味がわきませんでしたが、できればジョウ君とおそろいの景品が欲しいと思っています。

ヤエさんがやってみようと思うガチャポンは、１回のチャレンジで景品がひとつ出ます。品切れのものも含め景品が何種類あるのかと、それぞれの景品がいくつ残っているのかはわかります。しかし、1回のチャレンジでどの景品が出るかはわかりません。そこで、景品が出る順番にかかわらず、ヤエさんが同じ景品を必ず２つ得るために最低限必要なチャレンジの回数を出力するプログラムを作成してください。

入力

入力は複数のデータセットからなる。入力の終わりはゼロ1つの行で示される。各データセットは以下の形式で与えられる。

N
k1 k2 ... kN

各データセットは2行であり、1行目に景品が何種類あるかを表す整数N(1 ≤ N ≤ 10000)が与えられる。続く1行に各景品がいくつ残っているのかを表す整数ki(0 ≤ ki ≤ 10000)が与えられる。

データセットの数は100を超えない。

出力

データセットごとに、同じ景品を必ず２つ得るために最低限必要なチャレンジの回数を出力する。ただし、不可能な場合はNAと出力する。

入力例

2
3 2
3
0 1 1
1
1000
0

出力例

3
NA
2

１つ目のデータセットでは、運良く１種類目か２種類目の景品が連続で出て２回で済む可能性はあるが、同じ種類の景品を必ず２つ得るためには３回チャレンジする必要がある。

２つ目のデータセットでは、２つ以上残っている景品がもともと無いので不可能である。

３つ目のデータセットでは、景品は１種類だけなので２回のチャレンジでその景品が必ず２つ得られる。



Sample input:
2
3 2
3
0 1 1
1
1000
0


Sample output:
3
NA
2

Submission status: Wrong Answer

Solution code:
while True:
    n =	int(raw_input())
    if n == 0: break
    k =	map(int, raw_input().split())
    print "NA" if set(k) == set([0, 1]) else n - k.count(0) + 1

Submission status: Accepted

Solution code:
while 1:
    n = int(input())
    if n == 0:break
    k = [x for x in map(int,input().split()) if x >0]
    k2 = [x for x in k if x > 1]
    if len(k2) > 0:
        print(len(k)+1)
    else:
        print('NA')

Submission status: Accepted

Solution code:
while 1:
  n=int(input())
  if n==0: break
  a=list(map(int,input().split()))
  if max(a)<2:
    print("NA")
    continue
  print(len([x for x in a if x>0])+1)

Submission status: Accepted

Solution code:
while input()!="0":
  a=list(map(int,input().split()))
  print("NA" if max(a)<2 else sum(1 for x in a if x)+1)

Submission status: Accepted

Solution code:
import sys
f = sys.stdin

while True:
    n = int(f.readline())
    if n == 0:
        break
    k = [int(ki) for ki in f.readline().split()]
    k = [ki for ki in k if 0 < ki]
    print('NA' if len(k) == 0 or max(k) < 2 else len(k) + 1)

Submission status: Accepted

Solution code:
while True:
    n = input()
    if n == 0: break
    a = map(int, raw_input().strip().split(" "))
    sum = 0; ret = 0;
    for j in range(n):
        sum += a[j]
    for j in range(n):
        if a[j] > 0:
            ret+=1
            sum-=1
    if sum == 0: print "NA"
    else: print ret+1

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if n == 0:
        break
    Ko = list(map(int,input().split()))
    if Ko.count(0) + Ko.count(1) == len(Ko):
        print("NA")
    else:
        print(n - Ko.count(0) + 1)

Submission status: Accepted

Solution code:
while 1:
    n=int(input())
    if n==0:break
    a=list(map(int,input().split()))
    print([1+len([i for i in a if i>0]),"NA"][max(a)<2])

Submission status: Accepted

Solution code:
# Aizu Problem 0279: A Pair of Prizes

import sys, math, os, datetime

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


while True:
    n = int(input())
    if n == 0:
        break
    t = [int(_) for _ in input().split()]
    if max(t) < 2:
        print("NA")
    else:
        print(1 + len([i for i in t if i > 0]))

Submission status: Accepted

Solution code:
while 1:
    n = int(input())
    if n == 0:break
    p = list(map(int,input().split()))
    if max(p) < 2:
        print("NA")
        continue
    print(n - p.count(0) + 1)

Submission status: Accepted

Solution code:
# AOJ 0279: A Pair of Prizes
# Python3 2018.6.25 bal4u

while True:
	n = int(input())
	if n == 0: break
	k = list(map(int, input().split()))
	one, many = 0, 0
	for i in k:
		if i == 1: one += 1
		elif i > 1: many += 1
	print(one+many+1 if many > 0 else "NA")

Submission status: Accepted

Solution code:
while True:
  n = int(input())
  if n == 0:
    break
  klst = list(map(int, input().split()))
  for k in klst:
    if k >= 2:
      break
  else:
    print("NA")
    continue

  print(sum(list(map(bool, klst))) + 1)

Submission status: Accepted

Solution code:
while 1:
    n = input()
    if n==0: break
    k = map(int, raw_input().split())
    o = k.count(1); z = k.count(0);
    if len(k)==o+z:
        print "NA"
    else:
        print len(k)-z+1

Submission status: Accepted

Solution code:
while 1:
    n = input()
    if n==0: break
    k = map(int, raw_input().split())
    f = False
    for i in xrange(n):
        if k[i]>1:
            f = True; break;
    if f:
        print len(k)-k.count(0)+1
    else:
        print "NA"

Submission status: Accepted

Solution code:
while 1:
    n = input()
    if n==0: break
    k = map(int, raw_input().split())
    o = k.count(1); z = k.count(0);
    if o+z==n:
        print "NA"
    else:
        print n-z+1

Submission status: Accepted

Solution code:
while True:
    n =	int(raw_input())
    if n == 0: break
    k =	map(int, raw_input().split())
    c0 = c1 = 0
    for	c in k:
	if c ==	1: c1 += 1
	elif c == 0: c0 += 1
    print "NA" if c1 + c0 == n else n - c0 + 1

Submission status: Accepted

Solution code:
while 1:
	n=input()
	if n==0:break
	t=map(int,raw_input().split())
	if max(t)<2:
		print "NA"
		continue
	print 1+len([i for i in t if i>0])

Submission status: Accepted

Solution code:
while 1:
    n=input()
    if n==0:break
    t=map(int,raw_input().split())
    print "NA" if max(t)<2 else 1+len([i for i in t if i>0])

Submission status: Accepted

Solution code:
while True :
    n = int(input())
    if n == 0 :
        break
    
    s = list(map(int, input().split()))
    if max(s) < 2 :
        print('NA')
    else :
        t = s.count(0)
        print(n-t+1)

Submission status: Accepted

Solution code:
while True:
    ko = int(input())
    if ko == 0:break
    line = input().split()
    num = line.count("1") + line.count("0")
    if ko == num:
        print("NA")
        continue
    print(ko - line.count("0") + 1)

Submission status: Accepted

Solution code:
N=int(input())

while N!=0:
    K=list(map(int,input().split()))
    K=[i for i in K if i!=0]
    K_check=[i for i in K if i>=2]
    if len(K_check)==0:
        print("NA")
    else:
        print(len(K)+1)
    N=int(input())

Submission status: Accepted

Solution code:
while True:
    n = int(input())
    if n ==0:
        break

    k = list(map(int, input().split()))
    if n == 1:
        print(2)
    elif k.count(0) + k.count(1) == n:
        print("NA")
    else:
        print(n - k.count(0) + 1)

Submission status: Accepted

Solution code:
while 1:
  n = int(input())
  if n == 0:
    break
    
  data = list(map(int, input().split()))
  
  if n == 1:
    print(2)
  elif data.count(0) + data.count(1) == n:
    print('NA')
  else:
    print(n-data.count(0)+1)

Submission status: Accepted

Solution code:
while True:
  n=int(input())
  if n == 0: break
  a=list(map(int,input().split(" ")))
  if max(a)<2:
    print("NA")
  else:
    print(1+len([i for i in a if i>0]))

Submission status: Accepted

Solution code:
while 1:
  n = int(input())
  if n == 0: break
  a = list(map(int, input().split()))
  if max(a) < 2:
    print("NA")
    continue
  print(len([x for x in a if x > 0]) + 1)

Submission status: Accepted

Solution code:
while 1:
  n=int(input())
  if n==0: break
  a=list(map(int,input().split()))
  if max(a)<2:
    print("NA")
    continue
  print(len([x for x in a if x>0])+1)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
A Pair of Prizes
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0279

"""
import sys


def solve(K):
    if max(K) < 2:
        return 'NA'
    res = [k for k in K if k > 0]
    return len(res) + 1


def main(args):
    while True:
        N = int(input())
        if N == 0:
            break
        K = [int(k) for k in input().split()]
        ans = solve(K)
        print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

Solution code:
from collections import defaultdict
# A, B, C = [int(n) for n in input().split()]
while(True):
    N = int(input())
    if N == 0:
        break
    k = [int(n) for n in input().split()]
    dic = dict(zip([ i for i in range(len(k))], k))
    ans = 0
    for i in range(len(k)):
        if k[i] > 0:
            k[i] -= 1
            ans += 1
    print(ans + 1 if max(k) > 0 else "NA")

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

while True:
    N = int(input())
    if N == 0:
        break
    
    nums = [int(i) for i in input().split()]

    maxNum = 0
    cnt = 0
    for i in range(N):
        if nums[i] > 0:
            cnt = cnt + 1
        maxNum = max(nums[i], maxNum)
        
    if maxNum < 2:
        print("NA")
    else:
        print(cnt + 1)

Submission status: Accepted

Solution code:
while ( True ):
    n = int(input())
    if n == 0 : break
    ki = list(map(int, input().split()))
    less1Cnt = 0
    zeroCnt = 0
    for k in ki:
        if k <= 1 : less1Cnt += 1
        if k == 0 : zeroCnt += 1

    if n == less1Cnt : print("NA")
    else : print(n - zeroCnt + 1)

Submission status: Accepted

Solution code:
while 1:
    n=int(input())
    count=1
    if n==0:break
    k=list(map(int,input().split()))
    k.sort(reverse=True)
    if k[0]<2:print("NA")
    else:
        for i in k:
            if i!=0:count+=1
        print(count)

Submission status: Accepted

Solution code:
while 1:
    n = int(input())
    if n == 0:
        break

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

    if n == 1:
        print(2)
    elif data.count(0) + data.count(1) == n:
        print("NA")
    else:
        print(n-data.count(0)+1)

Submission status: Runtime Error

Solution code:
import sys
f = sys.stdin


while True:
    n = int(f.readline())
    if n == 0:
        break
    k = [int(ki) for ki in f.readline().split()]
    k = [ki for ki in k if 0 < ki]
    print('NA' if max(k) < 2 else len(k) + 1)