#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, counter1 = 0, counter2 = 0;
  cin >> n;
  char arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  for (int i = n - 1; i >= 0; i--) {
    if (arr[i] != '4' && arr[i] != '7') {
      cout << "NO" << endl;
      return 0;
    }
  }
  for (int i = 0; i < n / 2; i++) {
    counter1 += arr[i];
  }
  for (int i = n / 2; i < n; i++) {
    counter2 += arr[i];
  }
  if (counter1 == counter2)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
