#include <bits/stdc++.h>
using namespace std;
long long a[100000], b[100000];
int main() {
  long long n;
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
  }
  set<long long> st;
  for (long long i = n; i >= 1; i--) {
    b[i] = st.size();
    st.insert(a[i]);
  }
  set<long long> tt;
  long long ans = 0;
  for (long long i = 1; i < n; i++) {
    if (tt.find(a[i]) == tt.end()) {
      ans += b[i];
    }
    tt.insert(a[i]);
  }
  cout << ans;
}
