accesing vectors going out of bounds :     #include <iostream>
    #include<algorithm>
    #include<vector>
    using namespace std;


        int main()
    {
        int t;
        cin>>t;
        while(t--)
        { vector <int> a,b;
          int i,n,m,k;
          bool cond=true;
         cin>>n;
         for(i=0;i<n;i++)
         {
             cin>>m;
             a.push_back(m);
         }
         for(i=1;i<n-1;i++)
         {
             if(a.at(i)==a.at(i+1))
                a.erase(a.begin()+i);
         }
         n=a.size();
         for(i=0;i<n;i++)
            cout<<a[i];

        }
        return 0;
    }
i want to delete all the repetions of consecutive numbers why is the program throwing me an error of out of bounds????
is there any logical error.or could u give me some better logic