#include <bits/stdc++.h>
using namespace std;
int n, a[100001];
int cnt[100001];
bool vis[100001];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = n - 1; i >= 0; --i) {
    if (!vis[a[i]]) {
      vis[a[i]] = true;
      cnt[i] = cnt[i + 1] + 1;
    } else
      cnt[i] = cnt[i + 1];
  }
  long long ret = 0;
  memset(vis, 0, sizeof(vis));
  for (int i = 0; i < n; ++i) {
    if (!vis[a[i]]) {
      vis[a[i]] = true;
      ret += cnt[i + 1];
    }
  }
  cout << ret << '\n';
  return 0;
}
