#include <bits/stdc++.h>
typedef long long ll;

using namespace std;

ll MOD = (ll)1000000007;
vector<ll> nums;
int occ[26];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t, m, n;
    ll k, ans = 0;
    string s1, s2;
    bool sad = false;
    cin >> s1;
    for(int i = s1.size()-1; i >= 0; i--) {
        occ[s1.at(i)-'a']++;
        if(i != s1.size()-1) {
            if(s1.at(i) == s1.at(i+1)) {
                ans += s1.size() - i - occ[s1.at(i)-'a'];
                for(int j = 0; j < 26; j++) occ[j] = 0;
                occ[s1.at(i)-'a'] = s1.size()-i;
            }
        }
    }
    cout << ans << '\n';
}
#include <bits/stdc++.h>
#include <cassert>
#include <functional>
#define rep(i, N) for (int i = 0; i < (N); ++i)
#define rep2(i, a, b) for (ll i = a; i <= b; ++i)
#define rep3(i, a, b) for (ll i = a; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(c) begin(c), end(c)
#define ok() puts(ok ? "Yes" : "No");
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll, ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
// clang++ -std=c++11 -stdlib=libc++

int N;
int main() {
  cin >> N;
  vi p(N);
  rep(i, N) cin >> p[i];
  vector<int> used(200005);
  int mn = 0;
  rep(i, N) {
    int a = p[i];
    used[a] = true;
    while (mn == a || used[mn]) {
      mn++;
    }
    cout << mn << endl;
  }
  return 0;
}
