691A.md (1041B)
1 Source: https://codeforces.com/problemset/problem/691/A 2 3 A. Fashion in Berland 4 5 time limit per test 6 7 1 second 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 standard input 16 17 output 18 19 standard output 20 21 According to rules of the Berland fashion, a jacket should be fastened by all the buttons except only one, but not necessarily it should be the last one. Also if the jacket has only one button, it should be fastened, so the jacket will not swinging open. 22 23 You are given a jacket with *n* buttons. Determine if it is fastened in a right way. 24 25 Input 26 27 The first line contains integer *n* (1 ≤ *n* ≤ 1000) — the number of buttons on the jacket. 28 29 The second line contains *n* integers *a**i* (0 ≤ *a**i* ≤ 1). The number *a**i* = 0 if the *i*-th button is not fastened. Otherwise *a**i* = 1. 30 31 Output 32 33 In the only line print the word "YES" if the jacket is fastened in a right way. Otherwise print the word "NO". 34 35 Examples 36 37 Input 38 39 ``` 40 3 41 1 0 1 42 ``` 43 44 Output 45 46 ``` 47 YES 48 ``` 49 50 Input 51 52 ``` 53 3 54 1 0 0 55 ``` 56 57 Output 58 59 ``` 60 NO 61 ```