#include <bits/stdc++.h>
using namespace std;
int a[100005];
int f[100005];
int s[100005];
bool used[100005];
int main() {
  int n;
  scanf("%d", &n);
  ;
  for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
  memset(used, 0, sizeof(used));
  for (int i = n - 1; i >= 0; i--) {
    if (!used[a[i]]) {
      s[n - 1 - i] = s[n - i - 2] + 1;
      used[a[i]] = 1;
    } else {
      s[n - 1 - i] = s[n - i - 2];
    }
  }
  memset(used, 0, sizeof(used));
  long long ans = 0;
  for (int i = 0; i <= n - 2; i++) {
    if (!used[a[i]]) {
      used[a[i]] = 1;
      ans += s[n - 2 - i];
    }
  }
  cout << ans;
  return 0;
}
