#include <bits/stdc++.h>
#define ll long long int
using namespace std;

int main() {
	// your code goes here;
ios_base::sync_with_stdio(false);
cin.tie(NULL);
 ll t=1;
 //cin>>t;
 while(t--)
 {
    ll n;
    cin>>n;
    ll prmi=0;
    ll a[n];
    map<ll,ll>m;
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
        m[a[i]]=1;
        if(m[prmi]==0)
        {
         cout<<prmi<<endl;   
        }
        else{
         while(m[prmi]!=0)
         {
            prmi++;
         }
         cout<<prmi<<endl;
        }
    }
 }
}

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ull = unsigned long long;
using vll = vector<ll>;
using vi = vector<int>;
using vb = vector<bool>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vpll = vector<pll>;
const ll LINF = 1ll << 55;
const ll INF = 0x3f3f3f3f;
const ll MOD = 1e9 + 7;
const ll dx[] = {1, 0, -1, 0};
const ll dy[] = {0, 1, 0, -1};

/// cin/cout overloading
template <typename T>
ostream &operator<<(ostream &out, const vector<T> &vec) {
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    out << *it << " ";
  }
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const pair<T, T> &P) {
  out << P.first << " " << P.second;
  return out;
}

template <typename T>
istream &operator>>(istream &in, vector<T> &vec) {
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    in >> *it;
  }
  return in;
}

template <typename T>
istream &operator>>(istream &in, pair<T, T> &P) {
  in >> P.first >> P.second;
  return in;
}

#define error(args...)                       \
  {                                          \
    string _s = #args;                       \
    replace(_s.begin(), _s.end(), ',', ' '); \
    stringstream _ss(_s);                    \
    istream_iterator<string> _it(_ss);       \
    err(_it, args);                          \
    cerr << endl;                            \
  }

void err(istream_iterator<string>) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << ", ";
  err(++it, args...);
}

#define all(x) (x).begin(), (x).end()
#define coutp(x, y) cout << (x) << " " << (y) << endl
#define coutn(x) cout << (x) << endl
#define coutd(x) cout << setprecision(10) << (x) << endl

/// main函数
int main() {
  ll N;
  cin >> N;
  ll ans = 0;
  ll sqsum = 0;
  ll sumsq = 0;
  ll A;
  for (int i = 0; i < N; ++i) {
    cin >> A;
    sqsum += A * A;
    sumsq += A;
  }
  sumsq *= sumsq;
  ans = N * sqsum - sumsq;
  coutn(ans);
  return 0;
}
