#include <iostream>
using namespace std;

int main() 
{
	int n;
	int a[1000];
	cin>>n;
    int i;
	for (i=1;i<=n;i++)
		cin>>a[i];
	int l=1;
	for (i=2;i<=n;i++)
		if (a[i]!=a[i-1]) l++;
	cout<<(l*n)-1;
}
