原题链接:http://codeforces.com/contest/1041/problem/A

CF1041A Heist

There was an electronic store heist last night.

All keyboards which were in the store yesterday were numbered in ascending order from some integer number xxx. For example, if x=4x=4x=4 and there were 333 keyboards in the store, then the devices had indices 4,54, 54,5 and 666, and if
x=10x=10x=10 and there were 777 of them then the keyboards had indices 10,11,12,13,14,1510, 11, 12, 13, 14, 1510,11,12,13,14,15 and 161616.

After the heist, only nnn keyboards remain, and they have indices a1,a2,⋯ ,ana_1,a_2,\cdots,a_na1​,a2​,⋯,an​. Calculate the minimum possible number of keyboards that have been stolen. The staff remember neither xxx nor the number of keyboards in the store before the heist.

Input

The first line contains single integer n(1≤n≤1000)n(1≤n≤1000)n(1≤n≤1000) — the number of keyboards in the store that remained after the heist.

The second line contains nnn distinct integers a1,a2,⋯ ,an(1≤ai≤109)a_1,a_2,\cdots,a_n(1≤a_i≤10^9)a1​,a2​,⋯,an​(1≤ai​≤109) — the indices of the remaining keyboards. The integers aia_iai​ are given in arbitrary order and are pairwise distinct.

Output

Print the minimum possible number of keyboards that have been stolen if the staff remember neither xxx nor the number of keyboards in the store before the heist.

Examples
input

4
10 13 12 8

output

2

input

5
7 5 6 4 8

output

0

Note

In the first example, if x=8x=8x=8 then minimum number of stolen keyboards is equal to 222. The keyboards with indices 999 and 111111 were stolen during the heist.

In the second example, if x=4x=4x=4 then nothing was stolen during the heist.

题解

排序强校表示,排一遍序就能A (其实不用)。

代码
#include<bits/stdc++.h>
using namespace std;
int a[105],n;
void in(){scanf("%d",&n);for(int i=1;i<=n;++i)scanf("%d",&a[i]);}
void ac(){sort(a+1,a+1+n);printf("%d",a[n]-a[1]+1-n);}
int main(){in();ac();}

CF1041A Heist相关推荐

  1. 【题解】【CF1041A】Heist

    题意: 有许多的键盘,这些键盘的编号连续,但是某些键盘被偷了,现在给你剩下的键盘的编号,求被偷的键盘数量的最小值. 题解: 由于键盘编号连续,那么最少的键盘数量就一定是最大的键盘编号减去最小的键盘编号 ...

  2. [HTB]“Heist”靶机渗透详细思路

    今天我们来看一下hackthebox里的一个靶机"Heist",直接开始渗透. 一.信息搜集 先打开网站看看.是一个登陆框,使用弱口令和注入都无果.在网页中发现了 login as ...

  3. Honey Heist

    5092: Honey Heist 时间限制: 1 Sec  内存限制: 128 MB 题目描述 0x67 is a scout ant searching for food and discover ...

  4. Money Heist: 1 vulnhub walkthrough

    Money Heist: 1 虚拟机页面:http://www.vulnhub.com/entry/money-heist-1,592/ Description "The Professor ...

  5. Honey Heist(mcpc2017 )

    5092: Honey Heist 时间限制: 1 Sec  内存限制: 128 MB 提交: 27  解决: 10 [提交][状态][讨论版][命题人:admin] 题目描述 0x67 is a s ...

  6. mcpc2017 Honey Heist (模拟)

    5092: Honey Heist 时间限制: 1 Sec  内存限制: 128 MB 提交: 21  解决: 9 [提交][状态][讨论版][命题人:admin] 题目描述 0x67 is a sc ...

  7. HEIST攻击:从HTTPS加密数据中获取明文

    在Black Hat 2016大会上,两名比利时的安全研究人员展示了他们今年的研究成果.他们发现了一个WEB攻击方式可以绕过HTTPS加密得到明文信息.他们把这种攻击方式叫做HEIST攻击.HEIST ...

  8. 实战HackTheBox里的Heist

    首要是运行Nmap来查找主机上正在运行的服务. # Nmap 7.70 scan initiated Wed Aug 14 21:08:24 2019 as: nmap -A -p- -oN scan ...

  9. Vulnhub-Money Heist: 1

    靶机下载:点我 测试过程: 1.下载好靶机以后导入虚拟机,网络设置为VMnet8 2.打开虚拟机,需要用户名和密码登录,在这里,我们百度一下Ubuntu密码破解点我 3.进入系统后查看IP,发现不能获 ...

  10. 无需训练RNN或生成模型,我写了一个AI来讲故事

    作者 | Andre Ye 译者 | 弯月 出品 | AI科技大本营(ID:rgznai100) 这段日子里,我们都被隔离了,就特别想听故事.然而,我们并非对所有故事都感兴趣,有些人喜欢浪漫的故事,他 ...

最新文章

  1. 2022-2028年中国房车旅游行业深度调研及投资前景预测报告
  2. Windows Server 2008 R2入门之文件服务器
  3. Tomcat如何添加管理员
  4. 每日一皮:当我在重构时,总是有惊喜出现.......
  5. mysql 查询执行计划_mysql8 参考手册--了解查询执行计划,使用EXPLAIN优化查询
  6. Spark编程指南(Python版)
  7. Android 打造异常崩溃捕获工具
  8. Java黑皮书课后题第7章:**7.34(对字符串中的字符排序)使用以下方法头编写一个方法,返回一个排序好的字符串。编写一个测试程序,提示用户输入一个字符串,显示排序好的字符串
  9. 您一直在寻找5+个简单的一线工具来提升Python可视化效果
  10. Spark-三大数据结构之-广播变量
  11. 安卓软件错误log_Android编程实现捕获程序异常退出时的错误log信息功能详解
  12. Tomcate服务器的基本知识概括总结及安装目录概括
  13. shell中返回值是1为真还是假_肝!Shell 脚本编程最佳实践
  14. 【多线程】什么是线程安全?
  15. 525. Contiguous Array两位求和为1的对数
  16. C# 6.0 新特性
  17. 二、设置开发、运行环境 (基础教程2)
  18. OpenDRIVE编辑器TruevisionDesigner
  19. 数据结构试卷及答案(二)
  20. 代理模式-CGLIB动态代理

热门文章

  1. 神经网络与深度学习第5章:卷积神经网络 阅读提问
  2. 合肥青少年信息学计算机竞赛试题,合肥市第三十一届青少年信息学(计算机)竞赛 小学组试题...
  3. android 单手模式开发,单手操作毫无压力 安卓单指缩放技巧
  4. 单结晶体管的导电特性_【硬见小百科】二极管基础知识分类,应用,特性,原理,参数(二)...
  5. Mybatis和Spring整合逆向工程
  6. 日志分隔工具Cronolog
  7. hdu 4928 Series 2 (优化+模拟)
  8. linux中执行命令权限不够怎样处理
  9. hdu 1712 ACboy needs your help (DP)
  10. Delphi开发人员指南 第一部份快速开发的基础 第2章 Object Pascal 语言(二)