#include <bits/stdc++.h>
using namespace std;
int i, n, arr[100001], a[100001], cnt = 1, num, q;
bool fix[100001];
unsigned long long ans;
int main() {
  cin >> n;
  for (i = 1; i <= n; i++) {
    cin >> arr[i];
  }
  fix[arr[1]] = true;
  for (i = 2; i <= n; i++) {
    num = arr[i];
    q = cnt - a[num];
    ans += q;
    a[num] = cnt;
    if (!fix[num]) {
      cnt++;
      fix[num] = 1;
    }
  }
  cout << ans;
}
