#include <bits/stdc++.h>
using namespace std;
int main() {
  int T, Number, Size, counter = 0, sum1 = 0, sum2 = 0;
  char Word;
  cin >> T;
  Size = T / 2;
  while (T--) {
    cin >> Word;
    Number = (int)Word - '0';
    if (Number != 7 && Number != 4) {
      sum1 = 123;
      break;
    }
    if (counter < Size)
      sum1 += Number;
    else if (counter >= Size)
      sum2 += Number;
    counter++;
  }
  if (sum1 == sum2)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
