#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, a[N], f[N];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (!f[a[i]]) f[a[i]] = i;
  }
  set<int> s;
  long long ans = 0;
  for (int i = n; i >= 1; i--) {
    if (f[a[i]] == i) ans += s.size();
    s.insert(a[i]);
  }
  cout << ans;
  return 0;
}
