2018学校暑期集训第三天——几何基础

练习题F  ——   CodeForces - 1007A

Reorder the Array


You are given an array of integers. Vasya can permute (change order) its integers. He wants to do it so that as many as possible integers will become on a place where a smaller integer used to stand. Help Vasya find the maximal number of such integers.

For instance, if we are given an array [10,20,30,40][10,20,30,40], we can permute it so that it becomes [20,40,10,30][20,40,10,30]. Then on the first and the second positions the integers became larger (20>1020>10, 40>2040>20) and did not on the third and the fourth, so for this permutation, the number that Vasya wants to maximize equals 22. Read the note for the first example, there is one more demonstrative test case.

Help Vasya to permute integers in such way that the number of positions in a new array, where integers are greater than in the original one, is maximal.

Input

The first line contains a single integer nn (1≤n≤1051≤n≤105) — the length of the array.

The second line contains nn integers a1,a2,…,ana1,a2,…,an (1≤ai≤1091≤ai≤109) — the elements of the array.

Output

Print a single integer — the maximal number of the array's elements which after a permutation will stand on the position where a smaller element stood in the initial array.

Examples

Input

7
10 1 1 1 5 5 3

Output

4

Input

5
1 1 1 1 1

Output

0

Note

In the first sample, one of the best permutations is [1,5,5,3,10,1,1][1,5,5,3,10,1,1]. On the positions from second to fifth the elements became larger, so the answer for this permutation is 4.

In the second sample, there is no way to increase any element with a permutation, so the answer is 0.


#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;int a[100005];int main(void)
{int n;cin >> n;for(int i=0;i<n;i++)scanf("%d", &a[i]);int count=0;sort(a,a+n);for(int i=0;i<n;i++)if(a[i]>a[count])count++;cout << count << endl;return 0;
}

暑期集训3:几何基础 练习题F:  CodeForces - 1007A ​​​​​​​相关推荐

  1. 暑期集训3:几何基础 练习题H: POJ - 2456

    2018学校暑期集训第三天--几何基础 练习题H  --   POJ - 2456 Aggressive cows Farmer John has built a new long barn, wit ...

  2. 暑期集训3:几何基础 练习题G: HDU - 1052

    2018学校暑期集训第三天--几何基础 练习题G  --   HDU - 1052   (昨天加练题) Tian Ji -- The Horse Racing Here is a famous sto ...

  3. 暑期集训3:几何基础 练习题D:  HDU - 2036 ​​​​​​​

    2018学校暑期集训第三天--几何基础 练习题D  --    HDU - 2036 改革春风吹满地 " 改革春风吹满地,  不会AC没关系;  实在不行回老家,  还有一亩三分地.  谢谢 ...

  4. 暑期集训3:几何基础 练习题C: POJ - 1269

    2018学校暑期集训第三天--几何基础 练习题B --  POJ - 1269 Intersecting Lines We all know that a pair of distinct point ...

  5. 暑期集训3:几何基础 练习题B: HDU - 2001

    2018学校暑期集训第三天--几何基础 练习题B --  HDU - 2001 计算两点间的距离 输入两点坐标(X1,Y1),(X2,Y2),计算并输出两点间的距离. Input 输入数据有多组,每组 ...

  6. 暑期集训3:几何基础 练习题A: HDU - 2002

    2018学校暑期集训第三天--几何基础 练习题A  --   HDU - 2002 计算球体积 根据输入的半径值,计算球的体积. Input 输入数据有多组,每组占一行,每行包括一个实数,表示球的半径 ...

  7. 暑期集训5:并查集 线段树 练习题F:  HDU - 1166 ​​​​​​​

    2018学校暑期集训第五天--并查集 线段树 练习题F  --   HDU - 1166 敌兵布阵 C国的死对头A国这段时间正在进行军事演习,所以C国间谍头子Derek和他手下Tidy又开始忙乎了.A ...

  8. 暑期集训2:ACM基础算法 练习题G:POJ - 1298

    2018学校暑期集训第二天--ACM基础算法 练习题G  --  POJ - 1298 The Hardest Problem Ever Julius Caesar lived in a time o ...

  9. 暑期集训2:ACM基础算法 练习题C:CF-1008A

    2018学校暑期集训第二天--ACM基础算法 练习题A  --   CodeForces - 1008A Romaji Vitya has just started learning Berlanes ...

最新文章

  1. GitHub超4.1万星,最全Python入门算法来了
  2. react开发心路历程
  3. php中判断常量,变量,函数是否存在的方法示例
  4. Springboot集成netty实例
  5. 使用canvas绘制小程序码
  6. 参赛方案-主机托管、中小企业虚拟化应用
  7. 计算数字的位数并逆序输出
  8. 通过命令行获取计算机参数,Win32命令行参数的传到和获取
  9. Qt中SQL语句update同时更新多字段及设置字段值为空的方法
  10. 联通3G用户破千万 建成全球规模最大WCDMA网络
  11. bios刷写工具_蓝天P750/P751编程器刷BIOS
  12. ADC信噪比计算公式
  13. 谷尼国际软件-企业竞争情报系统
  14. STM32——PWM知识详解
  15. matlab程序特殊符号,MATLAB——matlab特殊符号表【转载】
  16. localhost 已拒绝连接
  17. 虚拟服务器磁盘读写慢,解决VMware Workstation虚拟机运行缓慢问题之修改硬盘参数及其虚拟硬盘的两种模式的说明...
  18. 从荣耀MagicV看折叠屏手机的现状及未来发展
  19. 音视频篇 - FFmpeg 的介绍和使用
  20. pythontext函数用法汇总_Python - Text Summarization

热门文章

  1. html input不可编辑
  2. 在windows中创建一个影子用户
  3. CGIC简明教程(转摘)
  4. 【转载】pycharm远程调试配置
  5. Python基础08-数据类型:集合set
  6. 三星android获取root权限,三星G9250(S6 Edge公开版全网通 Android 5.1)获取ROOT权限详解教程...
  7. java内部类 缺点_Java中的内部类及其优势
  8. 老年手机英文改中文_这些手游大作你都玩了吗?手机游戏推荐
  9. 快速了解Kubernetes微服务中的通信
  10. 在遗传算法中出现等式约束_排序算法中的稳定性-等式的处理