#include <bits/stdc++.h>
using namespace std;
const int N = 101000;
int n, seq[N], cnt[N], usd[N];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) scanf("%d", &seq[i]);
  for (int i = n; i; i--) {
    cnt[i] = cnt[i + 1] + (!usd[seq[i]]);
    usd[seq[i]] = 1;
  }
  memset(usd, 0, sizeof(usd));
  long long res = 0;
  for (int i = 1; i <= n; i++) {
    if (usd[seq[i]]) continue;
    res += cnt[i + 1];
    usd[seq[i]] = 1;
  }
  cout << res << endl;
  return 0;
}
