#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  set<int> aj;
  vector<int> isd(n, 0);
  for (int i = n - 1; i >= 0; i--) {
    isd[i] = aj.size();
    aj.insert(a[i]);
  }
  long long int ans = 0;
  vector<bool> inc_1(100005, false);
  for (int i = 0; i < n; i++) {
    if (!inc_1[a[i]]) {
      ans += isd[i];
      inc_1[a[i]] = true;
    }
  }
  cout << ans << "\n";
  return 0;
}
