#pragma GCC optimize("Ofast") #include using namespace::std; //struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout< // #include // #include // #include // #include // #include // #include // #include // #include // using boost::math::tools::brent_find_minima; // #include // #include // namespace mp = boost::multiprecision; // typedef mp::number> cdouble; // typedef mp::cpp_int cint; #include #include #include #include templateusing pbds=__gnu_pbds::tree,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>; templateusing pbds_map=__gnu_pbds::tree,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>; templateusing pqueue =__gnu_pbds::priority_queue,__gnu_pbds::rc_binomial_heap_tag>; typedef long long lint; typedef long long ll; typedef long double ldouble; typedef vector vec; typedef vector> mat; typedef vector>> mat3; typedef vector dvec; typedef vector> dmat; typedef vector>> dmat3; typedef vector svec; typedef vector> smat; typedef vector>> smat3; typedef vector> pvec; typedef vector>> pmat; typedef vector>>> pmat3; #define rep(i, n) for(lint i = 0; i < (lint)(n); i++) #define irep(i) for(lint i = 0;; i++) #define irep1(i) for(lint i = 1;; i++) #define irep2(i) for(lint i = 2;; i++) #define rrep(i, n) for(lint i = (lint)(n-1); i >-1; i--) #define rrepi(i,a,b) for(lint i = (lint)(b-1); i >a-1; i--) #define repi(i,a,b) for(lint i=lint(a);ilint(b);i+=c) #define all(x) (x).begin(),(x).end() #define PI 3.141592653589793 #define dist(x1,y1,x2,y2) (pow(pow(x2-x1,2)+pow(y2-y1,2),0.5)) #define output(v) do{bool f=0;for(auto i:v){cout<<(f?" ":"");if(i>INF/2)cout<<"INF";else cout<>n;vectora(n);rep(i,n)cin>>a[i]; #define SUM(v) accumulate(all(v),0LL) #define INF (1LL<<60) #define IINF (1<<30) #define EPS (1e-10) #define LINF 9223372036854775807 //#define MOD 998244353LL #define MOD 1000000007LL #define endl "\n" auto Y=[&](auto f){return[&](auto... args){return f(f, args...);};}; templateT in(){return *istream_iterator(cin);} templateinline T gcd(T a,T b){return b?gcd(b,a%b):a;} templateinline T lcm(T a,T b){return a/gcd(a,b)*b;} templateinline T add(T a,T b){return a+b;} templateinline T minq(T a,T b){return min(a,b);} inline bool chmin(auto& s,const auto& t){bool res=s>t;s=min(s,t);return res;} inline bool chmax(auto& s,const auto& t){bool res=s dx={-1,1,0,0,1,1,-1,-1}; vector dy={0,0,-1,1,1,-1,1,-1}; template class AVL_set{ struct node; using np=node*; struct node{ T val; int cnt=1; int dep=0; np ch[2]={nullptr,nullptr}; node(T val):val(val){} }; np root=nullptr; inline int count(np t){return t?t->cnt:0;} inline int depth(np t){return t?t->dep:0;} inline np update(np& t,bool f=1){ if(!t)return t; t->cnt=count(t->ch[0])+1+count(t->ch[1]); t->dep=max(depth(t->ch[0]),depth(t->ch[1]))+1; if(f&&abs(depth(t->ch[0])-depth(t->ch[1]))==2){ rebuild(t,depth(t->ch[0])ch[1])); } return t; } public: AVL_set(){} inline void insert(T val){insert(val,root);} inline void erase(T val){erase(val,root);} inline int lower_bound(T val){return lower_bound(val,root);} inline int upper_bound(T val){return upper_bound(val,root);} inline int size(){return count(root);} inline T find_by_order(int idx){assert(0<=idx&&idxval)return; else if(valval)insert(val,t->ch[0]); else if(val>t->val)insert(val,t->ch[1]); update(t); } void erase(T val,np& t){ if(!t)return; else if(val==t->val){ if(!t->ch[0]||!t->ch[1])t=t->ch[0]?t->ch[0]:t->ch[1]; else move_down(t->ch[0],t); } else if(valval)erase(val,t->ch[0]); else if(val>t->val)erase(val,t->ch[1]); update(t); } void move_down(np& t,np& p){ if(t->ch[1])move_down(t->ch[1],p); else p->val=t->val,t=t->ch[0]; update(t); } int lower_bound(T val,np t){ if(!t)return 0; if(val==t->val)return count(t->ch[0]); if(valval)return lower_bound(val,t->ch[0]); else return count(t->ch[0])+1+lower_bound(val,t->ch[1]); } int upper_bound(T val,np t){ if(!t)return 0; if(valval)return upper_bound(val,t->ch[0]); else return count(t->ch[0])+1+upper_bound(val,t->ch[1]); } T find_by_order(int idx,np t){ if(idx==count(t->ch[0]))return t->val; else if(idxch[0]))return find_by_order(idx,t->ch[0]); else return find_by_order(idx-count(t->ch[0])-1,t->ch[1]); } np rot(np t){ int b=depth(t->ch[0])ch[1]); if(depth(t->ch[0])==depth(t->ch[1]))return t; np s=t->ch[b]; t->ch[b]=s->ch[1-b]; s->ch[1-b]=t; update(t,0);update(s,0); return s; } void rebuild(np& t,int b){ if(t->ch[b]&&depth(t->ch[b]->ch[b])ch[b]->ch[1-b])){ t->ch[b]=rot(t->ch[b]); } t=rot(update(t,0)); } }; int main(){ lint n; cin>>n; vec a(n); rep(i,n)cin>>a[i]; lint ans=0; bool now=1; rep(i,n-1){ ans+=now; if(now&&a[i]!=a[i+1]){ now=0; }else{ now=1; } } ans+=now; cout<