Saleh127

CF 285C

Sep 4th, 2020
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define test int t; cin>>t; while(t--)
  5. ll a[1000000];
  6. int main()
  7. {
  8. ll c,d=0,i,j;
  9. cin>>c;
  10. for(i=1;i<=c;i++)
  11. {
  12. cin>>a[i];
  13. }
  14. sort(a+1,a+c+1);
  15. for(i=1;i<=c;i++)
  16. {
  17. d+=abs(a[i]-i);
  18. }
  19. cout<<d<<endl;
  20.  
  21. return 0;
  22. }
  23.  
Add Comment
Please, Sign In to add comment