#include <bits/stdc++.h>
using namespace std;
map<long long, long long> mp;
set<long long> st;
long long a[200005];
signed main() {
  long long n;
  long long ans = 0;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    mp[a[i]]++;
  }
  for (long long i = 0; i < n; i++) {
    mp[a[i]]--;
    if (mp[a[i]] == 0) mp.erase(a[i]);
    if (st.count(a[i]) == 0) {
      ans += mp.size();
      st.insert(a[i]);
    }
  }
  cout << ans << endl;
}
