from sys import stdin from random import randint from collections import deque, defaultdict as dd from copy import deepcopy input = stdin.readline MOD = 998244353 INF = 1 << 60 xor = randint(100, INF) def main(): n = int(input()) a = list(map(int, input().split())) ans = n*(n+1)//2+1 pre = a[0] cnt = 0 for i in range(n): if pre==a[i]: cnt += 1 else: ans -= cnt*(cnt+1)//2 pre = a[i] cnt = 1 ans -= cnt*(cnt+1)//2 print(ans) if __name__ == "__main__": main()