#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, a, b;
  cin >> n;
  if(n == 1) cout << "Hello World" << "\n";
  else cin >> a >> b, cout << a + b << "\n";
  return 0;
}

#include <iostream>
using namespace std;

int main() {
	int N;
	cin >> N;
	long long ans = 0, before;
	cin >> before;
	bool HasNoAns = (before > 0);
	for (int i = 1; i < N; i++) {
		int now;
		cin >> now;
		if (now == 0) {
			before = now;
			continue;
		}
		if (now == before + 1) ans++;
		else {
			if (now <= before) ans += now;
			else HasNoAns = true;
		}
		before = now;
	}
	cout << (HasNoAns ? -1 : ans) << endl;
}