#include <bits/stdc++.h>
using namespace std;
const unsigned long long maxm = 100010;
int main() {
  unsigned long long n, i, j, s, t, s1, s2, c;
  unsigned long long a[maxm], cnt[maxm], ans, b[maxm];
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> a[i];
  }
  c = 0;
  for (i = n; i >= 1; i--) {
    b[i] = c;
    cnt[a[i]]++;
    if (cnt[a[i]] == 1) {
      c++;
    }
  }
  memset(cnt, 0, sizeof(cnt));
  for (i = 1; i <= n; i++) {
    if (cnt[a[i]] == 0) {
      ans += b[i];
    }
    cnt[a[i]]++;
  }
  cout << ans << endl;
  return 0;
}
