#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  long long a[n];
  map<long long, long long> mp;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    mp[a[i]]++;
  }
  set<int> s;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    mp[a[i]]--;
    if (mp[a[i]] == 0) mp.erase(a[i]);
    if (s.find(a[i]) != s.end())
      continue;
    else {
      int x = n - (i + 1);
      ans += mp.size();
      s.insert(a[i]);
    }
  }
  cout << ans << endl;
}
