#include <bits/stdc++.h>

using namespace std;
int a[1005];
int main()
{
int n;
scanf("%d",&n);
int sum = 0;
int flag;
for(int i = 0; i < n; i ++)
{
scanf("%d",&a[i]);
if(a[i]==0){
sum ++;
}
}
if(n == 1)
{
if(a[0] == 1)
{
flag = 1;
}
else
{
flag = 0;
}
}
else
{
if(sum==1)
{
flag = 1;
}
else
{
flag = 0;
}
}
if(flag)
printf("YES\n");
else
printf("NO\n");
return 0;
}

题目描述:

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.

You are given a jacket with n buttons. Determine if it is fastened in a right way.

Input

The first line contains integer n (1 ≤ n ≤ 1000) — the number of buttons on the jacket.

The second line contains n integers ai (0 ≤ ai ≤ 1). The number ai = 0 if the i-th button is not fastened. Otherwise ai = 1.

Output

In the only line print the word "YES" if the jacket is fastened in a right way. Otherwise print the word "NO".

Example

Input
3
1 0 1
Output
YES
Input
3
1 0 0
Output
NO

H-Fashion in Berland的更多相关文章

  1. Educational Codeforces Round 14 A. Fashion in Berland 水题

    A. Fashion in Berland 题目连接: http://www.codeforces.com/contest/691/problem/A Description According to ...

  2. codeforces 691A A. Fashion in Berland(水题)

    题目链接: A. Fashion in Berland 题意: 思路: AC代码: //#include <bits/stdc++.h> #include <iostream> ...

  3. 【模拟】Codeforces 691A Fashion in Berland

    题目链接: http://codeforces.com/problemset/problem/691/A 题目大意: n个数0或1,要求恰好n-1个1,如果n为1则那个数一定要是1 题目思路: [模拟 ...

  4. Codeforces 691A Fashion in Berland

    水题. #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #includ ...

  5. Educational Codeforces Round 14

    A - Fashion in Berland 水 // #pragma comment(linker, "/STACK:102c000000,102c000000") #inclu ...

  6. Codeforces Round #375 (Div. 2)——D. Lakes in Berland(DFS连通块)

    D. Lakes in Berland time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  7. Codeforces Round #375 (Div. 2) D. Lakes in Berland dfs

    D. Lakes in Berland time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  8. codeforces 644A Parliament of Berland

    A. Parliament of Berland time limit per test 1 second memory limit per test 256 megabytes input stan ...

  9. CodeForces 164 B. Ancient Berland Hieroglyphs 单调队列

    B. Ancient Berland Hieroglyphs 题目连接: http://codeforces.com/problemset/problem/164/B Descriptionww.co ...

随机推荐

  1. 用 Scoop 管理你的 Windows 软件

    包管理系统,Homebrew 就是 macOS 上体验最佳的软件包管理,能帮助我们方便快捷.干净利落的管理软件.在Windows平台上也有一个非常棒的包管理软件--Scoop.Scoop 最适合安装那 ...

  2. VBA While Wend循环

    在While...Wend循环中,如果条件为True,则会执行所有语句,直到遇到Wend关键字. 如果条件为false,则退出循环,然后控件跳转到Wend关键字后面的下一个语句. 语法 以下是VBA中 ...

  3. centos+docker+jenkins

    1.直接运行jenkins镜像,无该镜像会直接下载 docker run -p 8080:8080 -p 50000:50000 -d -v /home/jenkins-home-docker:/va ...

  4. nginx 反向代理配置(一)

    文章参考:https://blog.csdn.net/physicsdandan/article/details/45667357       什么是代理?       代理在普通生活中的意义就是本来 ...

  5. HTTP协议超级详解

    HTTP协议简介 超文本传输协议(英文:HyperText Transfer Protocol,缩写:HTTP)是一种用于分布式.协作式和超媒体信息系统的应用层协议.HTTP是万维网的数据通信的基础. ...

  6. SAP Marketing Cloud功能简述(一) : Contacts和Profiles

    Dong Grace是Jerry的同事,目前是SAP成都研究院数字创新空间团队的一名实习生,明年7月才毕业.这篇文章是Grace对SAP Marketing Cloud功能梳理的一篇学习笔记,因为篇幅 ...

  7. Python标准库3.4.3-random

    9.6. random — Generate pseudo-random numbers Source code: Lib/random.py  翻译:Z.F. This module impleme ...

  8. git使用——忽略文件

    一般我们总会有些文件无需纳入 Git 的管理,也不希望它们总出现在未跟踪文件列表. 通常都是些自动生成的文件,比如日志文件,或者编译过程中创建的临时文件等.git下有2种方式实现忽略文件的目的.方法一 ...

  9. Windows Server 2016 IIS的安装与配置

    1. 打开服务器管理器,点击[添加角色和功能选项].        2. 进入“添加角色和功能向导”页面,点击下一步. 3. 安装类型选择[基于角色或基于功能的安装],点击下一步. 4. 进入服务器选 ...

  10. jmeter 5.1.1版本 进行抓包的时候弹出输入密码

    先描述一下如何配置Jmeter 先新建一个Thread Group,比如我命令为抓包 新建一个HTTP(S) Test Script Recorder,进行如下的配置, 配置端口,我这边设置为8899 ...