Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;

int main{
  int n; cin>>n;
  vector<int> num(n);
  
  rep(i,n) cin>>num[i];
  sort(num.begin,num.end);
  
  vector<int> sa(n-1);
  
  for (int i=1;i<n;i++){
    sa[i-1] = num[i] - num[i-1];
  }
  int ans=0
  rep(i,n-1)ans += sa[i];
  
  cout << ans << endl;
  return 0;
}
  
  
  
  

Compiler output:
a.cc:5:5: error: cannot declare '::main' to be a global variable
    5 | int main{
      |     ^~~~
a.cc:6:3: error: expected primary-expression before 'int'
    6 |   int n; cin>>n;
      |   ^~~
a.cc:6:3: error: expected '}' before 'int'
a.cc:5:9: note: to match this '{'
    5 | int main{
      |         ^
a.cc:6:10: error: 'cin' does not name a type
    6 |   int n; cin>>n;
      |          ^~~
a.cc:7:19: error: 'n' was not declared in this scope; did you mean 'yn'?
    7 |   vector<int> num(n);
      |                   ^
      |                   yn
a.cc:2:18: error: expected unqualified-id before 'for'
    2 | #define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
      |                  ^~~
a.cc:9:3: note: in expansion of macro 'rep'
    9 |   rep(i,n) cin>>num[i];
      |   ^~~
a.cc:2:35: error: expected constructor, destructor, or type conversion before '<' token
    2 | #define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
      |                                   ^
a.cc:9:3: note: in expansion of macro 'rep'
    9 |   rep(i,n) cin>>num[i];
      |   ^~~
a.cc:2:43: error: expected constructor, destructor, or type conversion before '++' token
    2 | #define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
      |                                           ^~
a.cc:9:3: note: in expansion of macro 'rep'
    9 |   rep(i,n) cin>>num[i];
      |   ^~~
a.cc:10:7: error: expected constructor, destructor, or type conversion before '(' token
   10 |   sort(num.begin,num.end);
      |       ^
a.cc:12:18: error: 'n' was not declared in this scope; did you mean 'yn'?
   12 |   vector<int> sa(n-1);
      |                  ^
      |                  yn
a.cc:14:3: error: expected unqualified-id before 'for'
   14 |   for (int i=1;i<n;i++){
      |   ^~~
a.cc:14:16: error: 'i' does not name a type
   14 |   for (int i=1;i<n;i++){
      |                ^
a.cc:14:20: error: 'i' does not name a type
   14 |   for (int i=1;i<n;i++){
      |                    ^
a.cc:2:18: error: expected ',' or ';' before 'for'
    2 | #define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
      |                  ^~~
a.cc:18:3: note: in expansion of macro 'rep'
   18 |   rep(i,n-1)ans += sa[i];
      |   ^~~
a.cc:2:35: error: expected constructor, destructor, or type conversion before '<' token
    2 | #define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
      |                                   ^
a.cc:18:3: note: in expansion of macro 'rep'
   18 |   rep(i,n-1)ans += sa[i];
      |   ^~~
a.cc:2:43: error: expected constructor, destructor, or type conversion before '++' token
    2 | #define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
      |                                           ^~
a.cc:18:3: note: in expansion of macro 'rep'
   18 |   rep(i,n-1)ans += sa[i];
      |   ^~~
a.cc:20:3: error: 'cout' does not name a type
   20 |   cout << ans << endl;
      |   ^~~~
a.cc:21:3: error: expected unqualified-id before 'return'
   21 |   return 0;
      |   ^~~~~~
a.cc:22:1: error: expected declaration before '}' token
   22 | }
      | ^